如何在div中制作CSS列?

发布于 2024-09-19 12:47:29 字数 388 浏览 5 评论 0原文

我正在对 WordPress 模板进行原型设计,并尝试将相同的元素放置在 header 上,如下所示:http://dl.dropbox.com/u/768097/about.pdf

以下是 HTML 和 CSS 文件:http://acreedy.oliveandpickle.com/

我需要在 header 中包含 4 列,并且所有内容都应放置在图像下方。

I am prototyping a Wordpress template and I'm trying to place the same elements on the header like this: http://dl.dropbox.com/u/768097/about.pdf

Here are the HTML and CSS files: http://acreedy.oliveandpickle.com/

I need 4 columns in the header and everything should be placed under the images.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野鹿林 2024-09-26 12:47:29

HTML:

<div id="header">

  <h1>Alan Creedy</h1>

    <ul id="quickInfo">
      <li class="mission">Mission Statement</li>
        <li>Helping People Think for Themselves</li>
        <li>1.919.926.0688</li>
        <li><a href="#contact">Email Me</a></li>
    </ul>

    <ul id="menu">
        <li class="current"><a href="#home">Home</a></li>
        <li><a href="#About">About</a></li>
        <li><a href="#BestPracticeIdeas">Best Practice Ideas</a></li>
        <li><a href="#ManagementTools">Management Tools</a></li>
        <li><a href="#Preneed">Preneed</a></li>
        <li><a href="#CaseStudies">Case Studies</a></li>
        <li><a href="#RecommendedResources">Recommended Resources</a></li>
        <li><a href="#ThinkTankForum">Think Tank Forum</a></li>    
    </ul>

</div>

CSS:

#header {
  border-bottom:3px solid #1582AB;
  height:200px;
  margin:0 auto;
  padding:46px 0 0;
  width:1000px;
  position:relative;
}
#header h1 {
  background:url("images/alan_creedy_headshot_transparent.png") no-repeat left top;
  font-size:40px;
  height:140px;
  padding:8px 0 0 215px;
  margin:0;
}
#quickInfo {
  position:absolute;
  right:10px;
  top:10px;
  width:400px;
}
#quickInfo li {
  list-style-type:none;
}
.mission {
  font-size:18px;
}
#menu {
  margin:0 auto;
  padding:0;
  width:1000px;
}

HTML:

<div id="header">

  <h1>Alan Creedy</h1>

    <ul id="quickInfo">
      <li class="mission">Mission Statement</li>
        <li>Helping People Think for Themselves</li>
        <li>1.919.926.0688</li>
        <li><a href="#contact">Email Me</a></li>
    </ul>

    <ul id="menu">
        <li class="current"><a href="#home">Home</a></li>
        <li><a href="#About">About</a></li>
        <li><a href="#BestPracticeIdeas">Best Practice Ideas</a></li>
        <li><a href="#ManagementTools">Management Tools</a></li>
        <li><a href="#Preneed">Preneed</a></li>
        <li><a href="#CaseStudies">Case Studies</a></li>
        <li><a href="#RecommendedResources">Recommended Resources</a></li>
        <li><a href="#ThinkTankForum">Think Tank Forum</a></li>    
    </ul>

</div>

CSS:

#header {
  border-bottom:3px solid #1582AB;
  height:200px;
  margin:0 auto;
  padding:46px 0 0;
  width:1000px;
  position:relative;
}
#header h1 {
  background:url("images/alan_creedy_headshot_transparent.png") no-repeat left top;
  font-size:40px;
  height:140px;
  padding:8px 0 0 215px;
  margin:0;
}
#quickInfo {
  position:absolute;
  right:10px;
  top:10px;
  width:400px;
}
#quickInfo li {
  list-style-type:none;
}
.mission {
  font-size:18px;
}
#menu {
  margin:0 auto;
  padding:0;
  width:1000px;
}
策马西风 2024-09-26 12:47:29

向左浮动肯定会解决您的问题,但请记住,每当您向浮动元素添加填充或边距时,您也必须调整宽度。我查看了您的页面,但您没有补偿该更改。相应地修复宽度,您应该可以开始了:D

~ Chris

http://twitter.com/TheCSSGuru

Floating left will most certainly fix your issue, though keep in mind whenever you add padding or margin to your floated element that you will have to adjust your width as well. I checked out your page and you didn't compensate that change. Fix the width accordingly and you should be good to go :D

~ Chris

http://twitter.com/TheCSSGuru

陌上芳菲 2024-09-26 12:47:29

如果您使用 html5,那么您可以使用side 或section 元素而不是div 的。

<style>
    .column {
             float: left;
             width: 200px;}
</style>

<aside class="column">
  Column1
</aside>
<section class="column">
  Column2
</section>
<section class="column">
  Column3
</section>
<section class="column">
  Column4
</section>

If you're using html5 then you could use aside or section elements instead of div's.

<style>
    .column {
             float: left;
             width: 200px;}
</style>

<aside class="column">
  Column1
</aside>
<section class="column">
  Column2
</section>
<section class="column">
  Column3
</section>
<section class="column">
  Column4
</section>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文