如何使页面左上方的徽标与其下方的文本对齐?另外,无论我将浏览器窗口的大小设置为多少,我都需要徽标与它下面的文本保持一致。我尝试更改block_header类的padding,margin和float设置,但是如果浏览器窗口未打开至正确的大小,则徽标和文本未对齐。这是我的CSS:

.main {width:100%; padding:0; margin:0 auto; min-width: 1020px; overflow: hidden;}
.header { background:url(images/slider_bgpng200.png); background-repeat: repeat-x; padding:0; margin:0 auto; width: 100%; }
.header .headertop{width: 100%; background: #d3e5e8; height: 30px;}
.block_header {margin:0 auto; width:1200px; padding:0; border:none; }
.space { float:left; padding:0; margin:0; }
.header_text { width:200px; float:right; font:normal 11px Tahoma, Geneva, sans-serif; color:#9a9a9a; padding:6px 10px 10px 10px; margin:0; text-align:center;}
.slider { background: transparent; margin:0 auto; padding:0; height:420px;}
.slider .gallery { margin:0 auto; width:980px; height:420px; padding:0;}
.slider .textholder {padding-top: 110px; float: left; width: 44%; font-family: 'Roboto', sans-serif; font-size: 40px; color: #93a0a2;padding-left: 30px;}
.formbox{float: right; width: 48%; padding-top: 90px; padding-right: 40px;}


这是html:

<div class="main">
 <div class="header">
   <div class="headertop"> <img src="images/avidestlogo50perresave.png"  border="0" alt="logo" />
     <div class="header_text"><a href="#">Email</a> | <a href="#">Client Login</a>
     </div>
   </div>
  <div class="block_header">
      <div class="space"><a href="index.html"></a>
      </div>
      <div class="slider">
         <div class="gallery">
            <div class="textholder">
            &nbsp;&nbsp;&nbsp;&nbsp;Where Student and <br />
            &nbsp;&nbsp;&nbsp;Alumni Freelancers <br />&nbsp;&nbsp;Get Hired
            </div>
            <div class = "formbox">Form is here
            </div>
         </div>
      </div>
  </div>
 </div>
</div>


该站点位于avidest.com/schneer上,因此您可以了解我在说什么。谢谢你的帮助。

最佳答案

徽标通常设置为CSS背景。然后,您可以结合使用边距和填充来在包含背景的元素内对齐文本。

<div class="logo">Welcome to XYZ</div>


CSS:

.title {
     background-image:url(...);
     background-repeat:no-repeat;
     height:60px;
     padding-left:50px; <-- move the text to the right of the logo
     padding-top:10px; <-- add a bit of whitespace at the top
     ...font styling etc...
}

关于css - 如何使页面左上方的徽标与其下方的文本对齐?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15145206/

10-11 11:52