如何才能使页面左上方的徽标与其下方的文字对齐?

时间:2013-02-28 20:39:26

标签: css position css-float alignment padding

如何制作,以便页面左上方的徽标与其下方的文字对齐?此外,无论我在浏览器窗口的大小,我都需要徽标与其下方的文本保持对齐。我已尝试更改block_header类的填充,边距和浮动设置,但如果浏览器窗口未打开到正确的大小,则徽标和文本不会对齐。这是我的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上,所以你可以看到我在说什么。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

徽标通常设置为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...
}