現在作成しているWebページのヘッダーを、画面サイズに合わせて子要素(logo,menu1~menu4)の比率を変えずに、かつ、背景画像が見切れることなく縮小したいのですが、どうすればいいでしょうか。
要素headerには幅、高さの指定はなし
headerの子要素のheadermenuのmax-widthは1034px
headermenuの子要素のlogo(サイトロゴ)は幅209px、高さ124px
menu1~menu4(メニューボタン)は幅170px、高さ48px です
ご提示よろしくお願いいたします。
HTML
1 <header id="header"> 2 <nav> 3 <ul id="headermenu"> 4 <li class="logo"><a href="http://example.co.jp">サイトロゴ</a></li> 5 <li class="buttons menu1"><a href="http://example.co.jp/hoge/">メニュー1</a></li> 6 <li class="buttons menu2"><a href="http://example.co.jp/hoge/">メニュー2</a></li> 7 <li class="buttons menu3"><a href="http://example.co.jp/hoge/">メニュー3</a></li> 8 <li class="buttons menu4"><a href="http://example.co.jp/hoge/">メニュー4</a></li> 9 </ul> 10 </nav> 11 </header>
css
1#header{ 2 display:block; 3 margin:0px auto; 4 padding:10px 0px 0px 0px; 5 text-align:center; 6} 7 8#header ul#headermenu{ 9 margin:0px auto; 10 padding:0px auto; 11 list-style: none outside; 12 text-align: left; 13 max-width:1034px; 14 background-color:rgba(128,128,128,0.8); 15 border-radius:1rem; 16} 17#header ul#headermenu li{ 18 display:inline-block; 19 vertical-align: middle; 20 text-align:left; 21 padding:0px; 22 position:relative; 23 text-indent:-10000px; 24} 25#header ul#headermenu li a{ 26 display:block; 27 width:100%; 28 height:100%; 29 overflow:hidden; 30 font-size:0px; 31 line-height:0px; 32 overflow:hidden; 33 background-repeat: no-repeat; 34} 35#header ul#headermenu li.logo{ 36 width:209px; 37 height:124px; 38 margin-right:20px; 39} 40#header ul#headermenu li.logo a{ 41 background-image:url("img/mainlogo.png"); 42 background-position: 0px 0px; 43} 44#header ul#headermenu li.buttons{ 45 background-image:url("img/headermenu.png"); 46 width:170px; 47 height:48px; 48 margin:16px 10px 0px 0px; 49 background-position: 0px 0px; 50 margin-bottom:17px; 51} 52#header ul#headermenu li.buttons:last-child{ 53 margin-right:0px !important; 54} 55#header ul#headermenu li.buttons.menu1{ 56 background-position: 0px 0px; 57} 58#header ul#headermenu li.buttons.menu1:hover{ 59 background-position: 0px -48px; 60} 61#header ul#headermenu li.buttons.menu2{ 62 background-position: -170px 0px; 63} 64#header ul#headermenu li.buttons.menu2:hover{ 65 background-position: -170px -48px; 66} 67#header ul#headermenu li.buttons.menu3{ 68 background-position: -340px 0px; 69} 70#header ul#headermenu li.buttons.menu3:hover{ 71 background-position: -340px -48px; 72} 73#header ul#headermenu li.buttons.menu4{ 74 background-position: -510px 0px; 75} 76#header ul#headermenu li.buttons.menu4:hover{ 77 background-position: -510px -48px; 78}
回答3件
あなたの回答
tips
プレビュー