gpt4 book ai didi

html - 为什么这段文字太远了? (HTML/CSS)

转载 作者:行者123 更新时间:2023-11-28 17:34:37 24 4
gpt4 key购买 nike

我正在尝试在我网页的某个部分添加文本/设置样式,但 div 总是以太低而告终。

HTML:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>.</title>
<link rel="stylesheet" type="text/css" href="theme.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<img src="logo.png" width=200px; height=100px; />
</div>
<nav id="nav" ><ul><li><a href="http://www.jukaijuiceco.com/why-juice/">About us</a>&emsp;&emsp;&emsp;</li>
<li><a href="http://www.jukaijuiceco.com/our-juices/">Locations</a>&emsp;&emsp;&emsp;</li>
<li><a href="http://www.jukaijuiceco.com/get-juice/">Contact us</a>&emsp;&emsp;&emsp;</li>
<li><a href="http://www.jukaijuiceco.com/about/">FAQ</a>&emsp;&emsp;&emsp;</li>
<li><a href="http://www.jukaijuiceco.com/about/">News</a>&emsp;&emsp;&emsp;</li>
<li><a href="http://www.jukaijuiceco.com/about/">Testemonials</a>&emsp;&emsp;&emsp;</li>
</ul></nav>
<div id="left-sidebar">
<h4>Flavors</h4>
<p class="desc">(Click on the pictures to learn more!)</p>
<br />
&nbsp;&nbsp;<img class="im" src="aca.jpg" height=100px; width=100px;><span class="desc">Smashmouth Acai&#0153;</span>
<br /><br /><br /><br /><br /><br />
&nbsp;&nbsp;<img class="im" src="apple.jpg" height=100px; width=100px;><span class="desc">Apple Attack&#0153;</span>
<br /><br /><br /><br /><br /><br />
&nbsp;&nbsp;<img class="im" src="berry.jpg" height=100px; width=100px;><span class="desc">Berry Bomb&#0153;</span>
<br /><br /><br /><br /><br /><br />
&nbsp;&nbsp;<img class="im" src="cran.jpg" height=100px; width=100px;><span class="desc">Crushing Cranberry&#0153;</span>
<br /><br /><br /><br /><br /><br />
&nbsp;&nbsp;<img class="im" src="mon.jpg" height=100px; width=100px;><span class="desc">Monkey Punch&#0153;</span>
</div>

<div class="main">
<p>Hi</p>
</div>

<div id="footer">
<a style="color: black;" href="http://tny.cz/6e848651">Copyright &copy; 2014 Jumpin Juice Inc.</a>
</div>
</div>
</body>

</html>

CSS:

body {
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
}
div {

}
#header{
border-color: lightblue; border-style:solid; border-width:1px;
background-color: lightblue;
clear: both;
width: 100%;
text-align: center;
}
.im{
margin-left: 10px;
float:left;
}
#nav{
font-size: 24px;
border-color: #33CC00; border-style:solid; border-width:1px;
background-color: #33CC00;
clear: both;
width: 100%;
height: 10%;
}

li {
list-style-type: none;
display: inline;
}

ul {
text-align: center;
}
.desc {
vertical-align:top;
text-align: center;
font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
}
a {
text-decoration: none;
color: white;
}
a:hover {
text-decoration: underline;
color: white;
}
h4 {
font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
font-size: 20px;
text-align: center;
}
#left-sidebar {
display:inline-block;
border-color: #FF9999; border-style:solid; border-width:1px;
background-color: #FF9999;
width: 20%;
}
#footer {
background-color: red;
color: black;
margin-bottom: 0px;
vertical-align:middle;
height: 40px;
font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
font-size: 15px;
}
.main {
display: inline;
}
.main p {
display: inline;
}

这会产生以下内容:

http://i.imgur.com/6eZWFVr.png

为什么会发生这种情况,我该如何解决才能在白色矩形的顶 Angular 显示“Hi”?

最佳答案

从 .main 中删除 display:inline; 样式并向左浮动 #left-sidebar。您还需要一个 clear:left; 在您的#footer 样式上:

#left-sidebar {
display:inline-block;
border-color: #FF9999; border-style:solid; border-width:1px;
background-color: #FF9999;
width: 20%;
float:left;
}
#footer {
background-color: red;
color: black;
margin-bottom: 0px;
vertical-align:middle;
height: 40px;
font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
font-size: 15px;
clear:left;
}
.main {
}

检查这个 fiddle ,看看它是否是你需要的:http://jsfiddle.net/ebejhrb5/1/

另外,这里有一个关于创建两列 CSS 布局的好资源:http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/

关于html - 为什么这段文字太远了? (HTML/CSS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25317188/

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