【发布时间】:2015-10-11 10:10:41
【问题描述】:
我想编写一个 CSS 脚本,其中包含 4 个 div 以及作为容器的第五个 div。
Div 1 应该在顶部作为标题,Div 2 应该在容器右侧的中心,Div 4(包含 img src)应该在容器的中心,Div 3 应该位于图像的底部。
我有一个脚本作为试用版,但它不像我想要的那样(我是 CSS 初学者)。
<html xmlns="http://www.w3.org/1999/html">
<head>
<title> </title>
<meta charset="utf-8">
<style>
#siena img {
display: inline-block;
margin-left: 0px;
}
#Container
{
margin-bottom: 3pc;
text-align: center;
border-width:2px;
border-color: #46b8da ;
margin-right: 100px;
margin-left: 100px;
border-style: solid;
background-color :#c4e3f3;
padding :10%;
}
#link
{
display: inline-block;
}
#price
{
top:100px;
width:50%
margin:0 auto;
float:right;
}
</style>
</head>
<body>
<meta charset="utf-8">
<h1 style="text-align: center;"> Text </h1>
<div id="Container" > <p>
<div id="siena" >
Text
<img src='http://www.traidnt.net/vb/attachments/480574d1272729780-no_pic.gif'>
<div id="price" >
price
</div>
</div>
<div id="link" >
<a href='https://www.google.com/?gws_rd=ssl' > </a>
</div>
</div>
</body>
</html>
【问题讨论】:
-
你需要 html 代码和 css 代码才能让它工作,你能告诉我们你到目前为止做了什么吗?
-
为了帮助您了解哪里出错了,我创建了这个colorcoded jsfiddle。我建议将来为不同的 DIV 添加背景颜色,以便更容易理解/学习如何使用 DIV 和 CSS 进行构建。