gpt4 book ai didi

html - 如何保证页眉水平展开时 float ?

转载 作者:行者123 更新时间:2023-11-28 04:52:27 24 4
gpt4 key购买 nike

怎样才能得到

News

与页面水平扩展而不是保持在左侧?

<!doctype html> <html> <head> <title>Technology - BBC News</title> <style type="text/css"> #topbar {
width: 1050px;
margin: 0 auto;
height: 40px;
}
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#logo {
margin-top: 8px;
width: 100px;
float: left;
margin-right: 8px;
}
.topbar-section {
float: left;
border-left: 1px #CCCCCC solid;
height: 100%;
}
#signin-image {
width: 25px;
margin: 11px 15px;
float: left;
}
#signin-text {
font-weight: bold;
font-size: 90%;
position: relative;
top: 14px;
padding-right: 50px;
}
#wigglyline {
float: left;
height: 40px;
}
#bell {
height: 25px;
margin: 9px 8px 0 8px;
}
#bell-div {
float: left;
}
.topbar-menu {
font-weight: bold;
font-size: 90%;
padding: 13px 15px 0 15px;
height: 27px;
}
#more-arrow {
width: 16px;
margin-left: 20px;
}
#searchbox {
background-color: #d3d3d3;
border;
none;
font-weight: bold;
font-size: 12px;
padding: 5px;
margin: -4px 0 5px;
float: left;
}
#magnifying-glass {
height: 27px;
margin-top: -4px;
}
.clear {
clear: both;
}
#menu-bar-container {
background-color: #9e2c25;
width: 100%;
height: 70px;
margin: 0 auto;
}
#menubar {
width: 1050px;
margin: 0 auto;
}
h1 {
padding: 10px;
margin: 0 auto;
color: white;
font-size: 40px;
font-weight: normal;
text-align: justify;
text-align-last: justify
}
</style> </head>
<body>

<div id="topbar">

<img id="logo" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\bbc-logo.png"></img>

<div id="signin-div" class="topbar-section">

<img id="signin-image" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\signinimage.png"></img>

<span id="signin-text">Sign in</span>

</div>

<div id="bell-div">

<img id="wigglyline" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\squiggle.png">

<img id="bell" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\bell.png">

</div>

<div class="topbar-section topbar-menu">

News

</div>

<div class="topbar-section topbar-menu">

Sports

</div>

<div class="topbar-section topbar-menu">

Weather

</div>

<div class="topbar-section topbar-menu">

iPlayer

</div>

<div class="topbar-section topbar-menu">

TV

</div>


<div class="topbar-section topbar-menu">

More

<img id="more-arrow" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\downarrow.png">

</div>

<div class="topbar-section topbar-menu">

<input id="searchbox" type="text" value="Search">

<input type="image" id="magnifying-glass" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\magnifying-glass.png">

</div>
</div>


<div class="clear"></div>

<div id="menu-bar-container">


<div id="menu-bar">

<h1>News</h1>


</div>





</div>









</body>

</html>

我已附加并更新了包含红色背景和新闻标题的 div 上方的搜索栏。水平展开浏览器页面时,您应该能够看到搜索栏如何 react 并继续随页面流动,而新闻标题仍位于页面左侧。

如果我需要以不同方式关闭 div 或改变位置,请告诉我。

本质上,我正在尝试让网站像这样运行:请点击链接 http://www.completewebdevelopercourse.com/content/2-css/bbc.html

最佳答案

您只是在您的 CSS 中忘记了破折号 (-)。它应该是 #menu-bar 而不是 #menubar

#topbar {
width: 1050px;
margin: 0 auto;
height: 40px;
}
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#logo {
margin-top: 8px;
width: 100px;
float: left;
margin-right: 8px;
}
.topbar-section {
float: left;
border-left: 1px #CCCCCC solid;
height: 100%;
}
#signin-image {
width: 25px;
margin: 11px 15px;
float: left;
}
#signin-text {
font-weight: bold;
font-size: 90%;
position: relative;
top: 14px;
padding-right: 50px;
}
#wigglyline {
float: left;
height: 40px;
}
#bell {
height: 25px;
margin: 9px 8px 0 8px;
}
#bell-div {
float: left;
}
.topbar-menu {
font-weight: bold;
font-size: 90%;
padding: 13px 15px 0 15px;
height: 27px;
}
#more-arrow {
width: 16px;
margin-left: 20px;
}
#searchbox {
background-color: #d3d3d3;
border;
none;
font-weight: bold;
font-size: 12px;
padding: 5px;
margin: -4px 0 5px;
float: left;
}
#magnifying-glass {
height: 27px;
margin-top: -4px;
}
.clear {
clear: both;
}
#menu-bar-container {
background-color: #9e2c25;
width: 100%;
height: 70px;
margin: 0 auto;
}
#menu-bar { /* Change this line! */
width: 1050px;
margin: 0 auto;
}
h1 {
padding: 10px;
margin: 0 auto;
color: white;
font-size: 40px;
font-weight: normal;
text-align: justify;
text-align-last: justify
}
<div id="topbar">

<img id="logo" src="http://www.completewebdevelopercourse.com/content/2-css/images/bbc-logo.png">

<div id="signin-div" class="topbar-section">

<img id="signin-image" src="http://www.completewebdevelopercourse.com/content/2-css/images/signinimage.png">
<span id="signin-text">Sign in</span>
</div>
<div id="bell-div">
<img id="wigglyline" src="http://www.completewebdevelopercourse.com/content/2-css/images/wigglyline.png">
<img id="bell" src="http://www.completewebdevelopercourse.com/content/2-css/images/bell.png">
</div>
<div class="topbar-section topbar-menu">

News

</div>

<div class="topbar-section topbar-menu">

Sports

</div>

<div class="topbar-section topbar-menu">

Weather

</div>

<div class="topbar-section topbar-menu">

iPlayer

</div>

<div class="topbar-section topbar-menu">

TV

</div>


<div class="topbar-section topbar-menu">

More

<img id="more-arrow" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\downarrow.png">

</div>

<div class="topbar-section topbar-menu">

<input id="searchbox" type="text" value="Search">

<input type="image" id="magnifying-glass" src="C:\Users\Kaitlyn\Desktop\Complete Web Developer Course\images\magnifying-glass.png">

</div>
</div>


<div class="clear"></div>

<div id="menu-bar-container">


<div id="menu-bar">

<h1>News</h1>


</div>





</div>

关于html - 如何保证页眉水平展开时 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40623693/

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