第二行不是从最左边的位置开始的?

时间:2014-07-07 12:35:35

标签: html css frontend

<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="utf-8">
        <title>Jack Yuan | Web Developer</title>
        <link rel="stylesheet" href="CSS/normalize.css">
        <link href='http://fonts.googleapis.com/css?family=Gloria+Hallelujah' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Lobster&subset=latin,cyrillic-ext' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="CSS/main.css">
        <link rel="stylesheet" href="CSS/responsive.css">

    </head>
    <body>

        <header>

            <a href="index.html" id="logo">
                <h1>Jack Yuan</h1>
                <h2>Web Developer</h2>
            </a>

            <nav>

                <ul>
                    <li><a href="about.html">About</a></li>
                    <li><a href="index.html">Portfolio</a></li>
                    <li><a href="item.html" class="selected"> Items For Sale </a> <li>
                    <li><a href="contact.html">Contact</a></li>
                </ul>

            </nav>
        </header>
        <div id="sec">
        <section>
            <ul id="item_gallery">
                    <li>
                    <a href="itemImg/001.JPG">
                    <img src="itemImg/001.JPG" width="100" height="100" alt="">
                    <p> Hard Choices </p>
                    </a></li>

                    <li>
                    <a href="itemImg/002.JPG">
                    <img src="itemImg/002.JPG"width="100" height="100"  alt="">
                    <p> Linear Algebra </p>
                    </a></li>

                    <li>
                    <a href="itemImg/003.JPG">
                    <img src="itemImg/003.JPG"width="100" height="100" alt="">
                    <p> Physics 111 + 112 </p>
                    </a></li>

                    <li>
                    <a href="itemImg/004.JPG">
                    <img src="itemImg/004.JPG"width="100" height="100" alt="">
                    <p> For BUS 111</p>
                    </a></li>

                    <li>        
                    <a href="itemImg/005.JPG">
                    <img src="itemImg/005.JPG" width="100" height="100" alt="">
                    <p> Chemistry for G11 </p>
                    </a></li>

                    <li>
                    <a href="itemImg/006.JPG">
                    <img src="itemImg/006.JPG"width="100" height="100"  alt="">
                    <p> Chinese-English Dictionary </p>
                    </a></li>

                    <li>
                    <a href="itemImg/007.JPG">
                    <img src="itemImg/007.JPG"width="100" height="100" alt="">
                    <p> English-Chinese Dictionary </p>
                    </a></li>

                    <li>
                    <a href="itemImg/008.JPG">
                    <img src="itemImg/008.JPG"width="100" height="100" alt="">
                    <p> Amath 250</p>
                    </a></li>

                    <li>
                    <a href="itemImg/009.JPG">
                    <img src="itemImg/009.JPG"width="100" height="100"  alt="">
                    <p> STAT 230 </p>
                    </a></li>

                    <li id="ten">
                    <a href="itemImg/010.JPG">
                    <img src="itemImg/010.JPG"width="100" height="100" alt="">
                    <p> CS116 </p>
                    </a></li>

                    <li id="eleven">
                    <a href="itemImg/011.JPG">
                    <img src="itemImg/011.JPG"width="100" height="100" alt="">
                    <p> For CS245</p>
                    </a></li>
                </ul>
        </section>
        </div>

        <footer>
            <div id="mus">
            <embed src="夜空中最亮的星 Calculasian.mp3" loop="true" autostart="true" height="55mm">
            <p> 夜空中最亮的星 </p> 
            <p>Presented by Calculasian </p>
            </div>
            <div id="logo">
            <a href="https://www.facebook.com/jackyuan.jack">
            <img src="img/facebook.gif" alt="FaceBook Logo" class="icon">
            </a>
            <a href="https://twitter.com/Jack19909100">
            <img src="img/twitter.png" alt="Twitter Logo" class="icon">
            </a>
            </div>
            <p>Jack Yuan</p>
            <p>All Rights Reserved.</p>
        </footer>

    </body>
</html>

这是我的CSS

a {
    text-decoration:none;
}



#logo {
    text-align: center;
    margin: 0;
}

h1 {
    margin: 0;
    padding-top: 4mm;
    font-size: 2em;
    font-family: 'Lobster', cursive;
    font-weight: normal;
    line-height: 0.8em;
}

h2 {
    font-family: 'Gloria Hallelujah', cursive;
    font-size: 1.5em;
    margin: -5px 0 0;
    font-weight: normal;
}

body{
    font-family: 'Gloria Hallelujah', cursive;
}

a {
    color: #6ab47b;
}

header{
    background: #6ab47b;
    border-color:#599a68;
    float:left;
    margin: 0;
    padding: 5px 0 0 0;
    width: 100%;
}

nav{
    background:  #599a68;
    text-align: center;
    margin: 20px 0 0;
}

nav a, nav a:visited {
    color:#fff;
}

nav ul{
    list-style: none;
    margin: 0 10px;
    padding: 0;
}



nav a{
    font-weight: 800;
    padding: 15px 10px;
}

h1, h2{
    color:#fff;
}

h3{
    margin: 0 0 1em 0;
}

nav a.selected , nav a:hover {
    color:#32673f;
}

footer{
    font-size: 1em;
    text-align: center;
    clear:both;
    padding-top: 20px;
    color: #ccc;
    line-height: 0.8em;
    background: black;
    padding-bottom: 1mm;
}


img{
    max-width: 100%;
}

#gallery img{   
    width: 100%;
}

#gallery{
    margin:0;
    list-style: none; /** remove bullet point **/
}



#gallery li{
    float:left;
    margin: 2.5%;
    background-color: #f5f5f5;
    color: #bdc3c7;
}

#gallery li a p{
    margin: 0;
    padding: 0;
    font-size: 1.5em;
    color: #bdc3c7;
}



.icon{
    width: 40px;
    height: 40px;
    margin: 5mm 5px;
}

body{
    background: orange;
    margin:0;
    color:#999;
}



/******
Page about
******/

.profile-photo{
    display:block;
    max-width:600px;
    margin:0 auto 30px;
    border-radius: 100%;
    padding-top: 10mm;
}



#confu{
    margin-top: 70mm;
}

#context{
    font-family: 'Montserrat', sans-serif; font-size: 1.5em;
}

#aboutsec{
    font-family: 'Pacifico', cursive; font-size:1.5em;
    text-align:center;
}



#mus p{
    margin-top:0;
    padding-top:0;
    line-height: 0.8em;
}

#item_gallery{
    margin:0;
    list-style:none;
}

#item_gallery li{
    float: left;
    padding-top: 22px;
    padding-right: 26px;
    padding-left: 26px;
    width:110px;
}

#item_gallery p,img{
    margin:0;
    padding: 0;
}


#sec{
    height:40cm;
}

我想在这里建立一个画廊。但是当我试图在第二行添加一个img时,它开始在行的中间而不是最左边的位置。我已经尝试过了&clear 34:left&#34;,但它没有用。有人可以帮忙吗?谢谢!

小提琴链接:http://jsfiddle.net/Arh63/

2 个答案:

答案 0 :(得分:4)

你可以试试这个:

删除float:left并使用display:inline-block;

Demo

#item_gallery li{
  display:inline-block;
  padding-top: 22px;
  padding-right: 26px;
  padding-left: 26px;
  width:110px;
  vertical-align:top;
}

答案 1 :(得分:0)

我刚删除了行<link href='http://fonts.googleapis.com/css?family=Gloria+Hallelujah' rel='stylesheet' type='text/css'>,它就开始工作了。可能这个字体设置有一些样式。

真的想知道!!

DEMO