在我的页面中,我想要它,以便当您调整页面大小超过图片点时,图片将进入另一行,一直到每张图片都有自己的行。然后可能我不需要任何媒体查询。但不幸的是,我找不到居中的方法。除了进行数百个具有不同定位的媒体查询之外,我已经尝试了所有我能想到的方法。我不能把它变成一个块,因为那样它就不会进入行,我试过 margin: 0 auto;。我尝试过更改填充,我什至尝试过使用 html align="center"。没有任何工作。这是网站http://spencedesign.netau.net/singaporehome.html我还有一个小问题,很抱歉用两个问题来解决这个问题。但是当它处于移动状态时,底部没有10px的内边距,新加坡标题在左侧而不是浮动的。这是我的代码
<html>
<head>
<title> Singapore - Home </title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial scale=1.0">
<style>
*
{
margin: 0;
padding: 0;
}
body
{
background: url('woodbackground.jpg');
background-size: cover;
min-height: 100%;
min-width: 100%;
position: relative;
top: 0; bottom: 0; left: 0; right: 0;
}
#container
{
width: 90%;
margin: 0 auto;
}
h1
{
font: bold 65px Helvetica, Arial, Sans-serif;
text-align: center;
color: #eee;
position: relative;
top: 60px;
}
h3
{
font: 25px Helvetica, Arial, Sans-serif;
text-align: center;
color: #eee;
position: relative;
top: 80px;
}
ul#gallery
{
list-style: none;
display: inline;
margin: 0 auto;
position: relative;
top: 175px;
width: 1300px;
}
ul#gallery li a
{
float: left;
padding: 10px 10px 25px 10px;
background-color: #eee;
border: 1px solid #fff;
-moz-box-shadow: 0px 2px 15px #333;
position: relative;
margin: 10px;
text-decoration: none;
}
ul#gallery li a:hover
{
position: relative;
top: -15px;
}
ul#gallery li a img
{
height: 150px;
width: 250px;
max-width: 100%;
}
ul#gallery li a p
{
margin-top: 25px;
text-align: center;
color: #000;
font: Helvetica, Arial, Sans-serif;
text-decoration: none;
font-size: 20px;
}
@media screen and (max-width: 640px)
{
ul#gallery
{
left: 2.2%;
width: 600px;
}
ul#gallery li a:hover
{
top: 0px;
}
}
</style>
<body>
<div id="container">
<h1> Singapore </h1>
<h3><i> Singapore is the worlds first machine that works </i>- Lee Kuan Yew </h3>
<ul id="gallery">
<li><a href="#"> <img src="gallery.jpg" alt="gallery" /> <p> Gallery </p> </a></li>
<li><a href="#"> <img src="facts.jpg" alt="facts" /> <p> Facts </p></a></li>
<li><a href="#"> <img src="tour.jpg" alt="tour" /> <p> Tour </p></a></li>
<li><a href="#"> <img src="author.jpg" alt="author" /> <p> Author </p> </a></li>
</ul>
<br/>
</div><!-- Container -->
</body>
<html>
谢谢!