【发布时间】:2016-06-01 09:50:24
【问题描述】:
我创建了一个网站,但无法使平铺布局响应。我是初学者,我不知道如何让我的网站响应。任何帮助将不胜感激。下面给出了css和html。另外,背景会重复 3 次,而我在 css 中没有添加重复属性。
HTML
<div class="grid">
<div class="tile hvr-reveal " id="tile1">
<div style="text-align: center;">
<div class="img-with-text ">
<p>
<strong>
<a href="Contact.html" style="text-decoration:none">Contact Us </a>
</strong>
<img src="homepage images/file242.png" alt="sometext" width="64" height="64" id="img0"/>
</p>
</div>
</div>
</div>
<div class="tile hvr-reveal" id="tile2">
<div style="text-align: center;">
<div class="img-with-text">
<p>
<strong>
<a href="products.html" style="text-decoration:none">Products</a>
</strong>
<img src="homepage images/shopping145.png" alt="sometext" width="64" height="64" id="img"/>
</p>
</div>
</div>
</div>
<div class="tile hvr-reveal " id="tile3">
<div style="text-align: center;">
<div class="img-with-text">
<p>
<strong>
<a href="partners.html" style="text-decoration:none">Partners</a>
</strong>
<img src="homepage images/celebration19.png" alt="sometext" width="64" height="64" id="img2"/>
</p>
</div>
</div>
</div>
<div class="tile hvr-reveal" id="tile4">
<div style="text-align: center;">
<div class="img-with-text">
<p>
<strong>
<a href="ABOUTUS.HTML" style="text-decoration:none">About Us</a>
</strong>
<img src="homepage images/men16.png" alt="sometext" width="64" height="64" id="img1"/>
</p>
</div>
</div>
</div>
</div>
CSS
body {
font-family: chewy;
color: #ffffff;
background-image: url(pictures%20for%20web/bg3.jpg) ;
background-position: center center;
background-attachment: fixed;
background-size: cover;
**strong text**background-repeat: no-repeat;
webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
.grid {
width: 1140px;
height: 650px;
margin: auto;
}
.tile {
position: absolute;
width: 200px;
left: 451px;
top: 152px;
height: 152px;
box-sizing: border-box;
}
#tile1 {
top: 407px;
left: 754px;
width: 338px;
height: 196px;
margin-left: 2px;
margin-right: 2px;
background-color: #ff3300;
}
#tile2 {
margin-left: 2px;
margin-right: 2px;
top: 100px;
left: 980px;
width: 148px;
height: 154px;
background-color: #008000;
}
#tile3 {
top: 255px;
left: 523px;
width: 200px;
height: 150px;
background-color: #660066 ;
margin-left: 2px;
margin-right: 2px;
}
#tile4 {
top: 255px;
left: 118px;
width: 200px;
height: 150px;
background-color: #990000;
margin-left: 2px;
margin-right: 2px;
}
【问题讨论】:
-
您会发现很多文章解释了响应式设计的工作原理。只需搜索它们,当您遇到问题时,我们很乐意提供帮助:)
-
如果您是初学者,请使用已构建网格系统的 Bootstrap。 getbootstrap.com/css/#grid
-
一些对你有帮助的东西 - 使用百分比而不是 px 作为宽度。这样,当您调整客户端大小时,您的图块会适当缩放。另外,你应该尽量避免
position: absolute;。这会扰乱您的瓷砖相互响应的方式。就像上面的评论一样,响应式设计的教程很容易找到,可以让你从右脚开始
标签: css html responsive-design grid dreamweaver