gpt4 book ai didi

css - 如何扩展我的边栏内容的长度?

转载 作者:太空宇宙 更新时间:2023-11-03 21:48:06 25 4
gpt4 key购买 nike

我的网站:http://web.njit.edu/~dp257/boilerplate/website.html#

我希望我的侧边栏向下延伸到页脚顶部或与我的内容长度相同。我所以我不想使用 JQuery 或类似的东西。我确定它必须在 CSS 中应该很容易修复,但我一头雾水。

   <div id = "wrapper">
<header id="name" align="center">MY IS117 Website</header>
<div id="primary_links" align="center">
<ul>
<li><a href="#">Menu 1</a></li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
<li><a href="#">Menu 5</a></li>
</ul>
</div>
<div id="content">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit eros, lacinia non mauris at, facilisis iaculis sem. Aenean eu felis elit. Aenean nec sem ac lectus aliquet sagittis eget sit amet urna. Etiam in dignissim nulla. In non nibh pharetra, posuere mi venenatis, consequat ipsum. Quisque dapibus porttitor posuere. Maecenas porttitor nibh sit amet lacinia vehicula. Nullam sit amet urna gravida, gravida leo vel, ultrices ante. Sed accumsan nibh nec erat dapibus, ut ultrices nisi elementum. Praesent in enim at nunc consectetur cursus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur quis scelerisque ipsum. Quisque vulputate consectetur egestas. Etiam non tincidunt urna.
</p>
<p>
Aenean fringilla sed urna a ultrices. Aliquam non augue in libero venenatis sodales at ut eros. Nunc ac arcu a justo luctus ultricies. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas sed molestie leo, vel placerat massa. Nullam at eros ac nunc malesuada fermentum nec vel mi. Nulla convallis mattis facilisis. Vivamus urna quam, tincidunt id venenatis in, porttitor quis lectus. Donec eu vehicula quam, sit amet sollicitudin risus. Nullam nec dapibus tortor. Nam in consectetur urna. Aenean enim eros, ullamcorper vitae mauris at, sollicitudin blandit felis. Ut ac odio blandit, sodales tortor sed, aliquam est.
</p>
<p>
Praesent at sagittis augue. Sed libero ipsum, pharetra eget ante nec, laoreet tempor leo. Cras libero magna, mattis in ligula a, rutrum volutpat libero. Morbi tincidunt lectus eget vehicula eleifend. Nullam pulvinar sapien non porttitor pharetra. Fusce porttitor nunc sit amet iaculis rhoncus. Nullam et est vel enim commodo interdum ac vel odio. Duis pretium lorem ante, condimentum laoreet lectus aliquam at. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent ornare dui vel erat hendrerit, commodo tempus eros vehicula. Morbi dapibus est tristique ligula consequat adipiscing. Nulla non massa nibh. Praesent justo quam, eleifend sed blandit eget, pharetra in augue.
</p>
<p>
Vestibulum tincidunt erat at justo adipiscing condimentum. Morbi ante eros, sagittis at augue a, feugiat malesuada quam. Mauris molestie leo a mi accumsan pretium. Vestibulum tempus mi et sagittis convallis. In ac purus porta nisi congue condimentum. Donec augue lectus, eleifend consectetur suscipit sit amet, volutpat sed enim. Quisque eget enim erat. Cras molestie nisi sed leo elementum, et eleifend est sollicitudin. Quisque sed elit at massa tincidunt vehicula sed non leo. Aenean condimentum, purus et consectetur auctor, nunc diam porttitor sapien, rutrum accumsan nisi lectus at ipsum. Duis blandit nulla felis, a dictum odio egestas pretium. Nullam feugiat justo mi, vel pretium mauris posuere vitae. Duis at adipiscing tortor. Morbi laoreet augue vel ullamcorper venenatis.
</p>
<p>
In porttitor orci nec turpis tempus, in faucibus mauris luctus. Aliquam egestas convallis sollicitudin. Sed congue, ante id porttitor tristique, odio purus molestie lectus, id egestas nisl magna vitae felis. Donec imperdiet lectus sem, vel varius sem aliquam vel. Morbi quis leo suscipit, vulputate nisi at, posuere velit. Duis lorem justo, pharetra id mi ut, egestas laoreet dui. Mauris ultricies libero sit amet ligula porttitor, eget sagittis neque ornare. Suspendisse tristique metus nec auctor volutpat.
</p>
</div>
<!-- content -->
<div id="sidebar">
<div id="secondary_links">
<ul>
<li><a href="#">Menu 1</a></li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
<li><a href="#">Menu 5</a></li>
</ul>
</div>
</div>
<div id="footer">Footer</div>
</div>
<!-- wrapper -->

CSS

#header {
background-color: cyan;
width: 100px;
height: 100px;
padding: 20px;
margin: 30px;
border: 5px solid;
}

#name {
border: 1px solid;
padding-left: 31px;
padding-right: 31px;
margin-left: auto;
margin-right: auto;
}

#wrapper {
width: 898px;
margin-left: auto;
margin-right: auto;
}

#primary_links li {
display: inline;
}

#primary_links {
height: 75px;
line-height: 75px;
border: 1px solid;
}

#primary_links a {
color: black;
}

#secondary_links ul, #primary_links ul {
margin: 0px;
padding: 0px;
}

#secondary_links li {
list-style: none;
/* gets rid of bullets */;
}

#sidebar {
width: 338px;
float: left;
border: 1px solid;
}

#secondary_links {
/*width:340px; temporary
float:right; put in own div fiix prob*/;
}

#footer {
/*margin-left:508px;
margin-right:230px;*/
clear: both;
background-color: green;
}

#content {
width: 508px;
padding-left: 23px;
padding-right: 23px;
border: 1px solid;
float: left;
}

最佳答案

你想让你的侧边栏在右边吗?与您的内容具有相同的高度?如果这是正确的,您可以在 #sidebar 上使用 float: right;。将您的内容和侧边栏放在一个新的 div 中,给他一个类:.wrapper。并在 .wrapper 上设置背景图片。如果高度改变,背景也会改变,背景也会重复。

.wrapper {
width: 100%;
background: url('yourimage') repeat;
/* float: left; */
overflow: hidden;
}

我希望你明白这一点。如果你愿意,我也可以给你举个例子。

编辑:您可以使用 float left 来为父级 div 提供子级的高度。或者您可以使用 overflow: hidden;

关于css - 如何扩展我的边栏内容的长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19306104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com