2016-08-19 51 views
0

好吧,我正在關注一個關於製作簡單投資組合網站的樹屋教程。他們有照片應該排列在網格中。我正在使用視頻,但我試圖切換圖片,這沒有什麼區別。我的照片全部仍然位於左側的一列,然後右側的照片應該位於右側。我會想象我錯過了某種結束標記或某種東西,但我找不到它。你介意看看它嗎?謝謝。爲什麼照片排列而不是網格(HTML + CSS)?

HTML:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <title>Carter Goff | Portfolio</title> 
    <link rel="stylesheet" href="css/normalize.css"> 
    <link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Oswald:300,400,700' rel="stylesheet"> 
    <link rel="stylesheet" href="css/style.css"> 
    </head> 
    <body> 
    <header> 
     <a href="index.html" id = "logo"> 
     <h1>Carter Goff</h1> 
     <h2>Choreographer</h2> 
     </a> 
     <nav> 
     <ul> 
      <li><a href="index.html">Home</a></li> 
      <li><a href="portfolio.html" class="selected">Portfolio</a></li> 
      <li><a href="about.html">About</a></li> 
      <li><a href="contact.html">Contact</a></li> 
     </ul> 
     </nav> 
    </header> 
    <div id="wrapper"> 
     <section> 
     <ul id = "gallery"> 
      <li> 
      <a href="vid/vid1.mp4"> 
       <video controls> 
       <source src="vid/vid1.mp4" type="video/mp4"> 
       Your browser does not support the video tag. 
       </video> 
      </a> 
      <a href="vid/vid1.mp4"> 
       <video controls> 
       <source src="vid/vid1.mp4" type="video/mp4"> 
       Your browser does not support the video tag. 
       </video> 
      </a> 
      </li> 
     </ul> 
     </section> 
     <footer> 
     <a href="http://instagram.com/cartergoffofficial"><img src="img/instagram.png" alt="Instagram Logo"></a> 
     <a href="https://www.facebook.com/carter.goff.52"><img src="img/facebook.png" alt ="Facebook Logo"></a> 
     <p>&copy; 2016 Carter Goff</p> 
     </footer> 
    </div> 
    </body> 
</html> 

和CSS:

/************************ 
GENERAL 
*************************/ 

body { 
    font-family: 'Open Sans Condensed', sans-serif; 
} 

#wrapper { 
    max-width: 940px; 
    margin: 0 auto; 
    padding: 0 5%; 
} 

a { 
    text-decoration: none; 
} 

video{ 
    max-width: 100%; 
} 



/************************ 
HEADING 
************************/ 

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

h1 { 
    font-family: 'Oswald', sans-serif; 
    margin: 15px 0; 
    font-size: 2em; 
    font-weight: normal; 
    line-height: 0.8em; 
} 

h2 { 
    font-size: 0.75em; 
    margin: -5px 0 0; 
    font-weight: normal; 
} 



/************************ 
NAVIGATION 
************************/ 

nav { 
    text-align: center; 
    padding: 10px 0; 
    margin: 20px 0 0; 
} 



/************************ 
FOOTER 
************************/ 

footer { 
    font-size: 0.75em; 
    text-align: center; 
    clear: both; 
    padding-top: 50px; 
    color: #ccc; 
} 



/************************ 
PAGE: PORTFOLIO 
************************/ 

#gallery { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
} 

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

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


/************************ 
COLORS 
************************/ 

/* site body */ 
body{ 
    background-color: #fff; 
    color: #b3b3b3; 
} 

/* pink header */ 
header{ 
    border-color: #ffb3ff; 
    background: #000000; 
} 

/* nav background on mobile */ 
nav{ 
    background: #ffb3ff; 
} 

/* logo text */ 
h1, h2 { 
    color: #fff; 
} 

/* links */ 
a { 
    color: #00ffb3; 
} 

/* nav links */ 
nav a, nav a:visited { 
    color: #000; 
} 

/* selected nav link */ 
nav a.selected, nav a:hover { 
    color: #b300b3 
} 
+0

需要跟蹤您的問題的演示 – kollein

回答

0

我想你錯過了將圖像分割成2 「裏」,而不必內外相同的 「禮」

+0

非常感謝。這是問題所在。 –

0

您的視頻都在同一li。但根據你的樣式表定義,你應該分別在li之間。

下面的代碼

   Your browser does not support the video tag. 
      </video> 
      </a> 
      <a href="vid/vid1.mp4"> 

應改爲

   Your browser does not support the video tag. 
      </video> 
      </a> 
     </li> 
     <li> 
      <a href="vid/vid1.mp4"> 

/************************ 
 
GENERAL 
 
*************************/ 
 

 
body { 
 
    font-family: 'Open Sans Condensed', sans-serif; 
 
} 
 
#wrapper { 
 
    max-width: 940px; 
 
    margin: 0 auto; 
 
    padding: 0 5%; 
 
} 
 
a { 
 
    text-decoration: none; 
 
} 
 
video { 
 
    max-width: 100%; 
 
} 
 
/************************ 
 
HEADING 
 
************************/ 
 

 
#logo { 
 
    text-align: center; 
 
    margin: 0; 
 
} 
 
h1 { 
 
    font-family: 'Oswald', sans-serif; 
 
    margin: 15px 0; 
 
    font-size: 2em; 
 
    font-weight: normal; 
 
    line-height: 0.8em; 
 
} 
 
h2 { 
 
    font-size: 0.75em; 
 
    margin: -5px 0 0; 
 
    font-weight: normal; 
 
} 
 
/************************ 
 
NAVIGATION 
 
************************/ 
 

 
nav { 
 
    text-align: center; 
 
    padding: 10px 0; 
 
    margin: 20px 0 0; 
 
} 
 
/************************ 
 
FOOTER 
 
************************/ 
 

 
footer { 
 
    font-size: 0.75em; 
 
    text-align: center; 
 
    clear: both; 
 
    padding-top: 50px; 
 
    color: #ccc; 
 
} 
 
/************************ 
 
PAGE: PORTFOLIO 
 
************************/ 
 

 
#gallery { 
 
    margin: 0; 
 
    padding: 0; 
 
    list-style: none; 
 
} 
 
#gallery li { 
 
    float: left; 
 
    width: 45%; 
 
    margin: 2.5%; 
 
    background-color: #f5f5f5; 
 
    color: #bdc3c7; 
 
} 
 
#gallery li a p { 
 
    margin: 0; 
 
    padding: 5%; 
 
    font-size: 0.75em; 
 
    color: #bdc3c7 
 
} 
 
/************************ 
 
COLORS 
 
************************/ 
 

 
/* site body */ 
 

 
body { 
 
    background-color: #fff; 
 
    color: #b3b3b3; 
 
} 
 
/* pink header */ 
 

 
header { 
 
    border-color: #ffb3ff; 
 
    background: #000000; 
 
} 
 
/* nav background on mobile */ 
 

 
nav { 
 
    background: #ffb3ff; 
 
} 
 
/* logo text */ 
 

 
h1, 
 
h2 { 
 
    color: #fff; 
 
} 
 
/* links */ 
 

 
a { 
 
    color: #00ffb3; 
 
} 
 
/* nav links */ 
 

 
nav a, 
 
nav a:visited { 
 
    color: #000; 
 
} 
 
/* selected nav link */ 
 

 
nav a.selected, 
 
nav a:hover { 
 
    color: #b300b3 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <title>Carter Goff | Portfolio</title> 
 
    <link rel="stylesheet" href="css/normalize.css"> 
 
    <link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Oswald:300,400,700' rel="stylesheet"> 
 
    <link rel="stylesheet" href="css/style.css"> 
 
</head> 
 

 
<body> 
 
    <header> 
 
    <a href="index.html" id="logo"> 
 
     <h1>Carter Goff</h1> 
 
     <h2>Choreographer</h2> 
 
    </a> 
 
    <nav> 
 
     <ul> 
 
     <li><a href="index.html">Home</a> 
 
     </li> 
 
     <li><a href="portfolio.html" class="selected">Portfolio</a> 
 
     </li> 
 
     <li><a href="about.html">About</a> 
 
     </li> 
 
     <li><a href="contact.html">Contact</a> 
 
     </li> 
 
     </ul> 
 
    </nav> 
 
    </header> 
 
    <div id="wrapper"> 
 
    <section> 
 
     <ul id="gallery"> 
 
     <li> 
 
      <a href="vid/vid1.mp4"> 
 
      <video controls> 
 
       <source src="vid/vid1.mp4" type="video/mp4"> 
 
       Your browser does not support the video tag. 
 
      </video> 
 
      </a> 
 
     </li> 
 
     <li> 
 
      <a href="vid/vid1.mp4"> 
 
      <video controls> 
 
       <source src="vid/vid1.mp4" type="video/mp4"> 
 
       Your browser does not support the video tag. 
 
      </video> 
 
      </a> 
 
     </li> 
 
     </ul> 
 
    </section> 
 
    <footer> 
 
     <a href="http://instagram.com/cartergoffofficial"> 
 
     <img src="img/instagram.png" alt="Instagram Logo"> 
 
     </a> 
 
     <a href="https://www.facebook.com/carter.goff.52"> 
 
     <img src="img/facebook.png" alt="Facebook Logo"> 
 
     </a> 
 
     <p>&copy; 2016 Carter Goff</p> 
 
    </footer> 
 
    </div> 
 
</body> 
 

 
</html>

1

你有一個li有兩個視頻在那裏,但通過看看CSS我看到你有li {float: left; width: 45%; margin: 2,5%},這隻會有意義,如果有不止一個李,所以我假設你想要兩個li的每一個視頻。如果我改變你的HTML結構我只是說你的CSS完美的作品:

/************************ 
 
GENERAL 
 
*************************/ 
 

 
body { 
 
    font-family: 'Open Sans Condensed', sans-serif; 
 
} 
 

 
#wrapper { 
 
    max-width: 940px; 
 
    margin: 0 auto; 
 
    padding: 0 5%; 
 
} 
 

 
a { 
 
    text-decoration: none; 
 
} 
 

 
video{ 
 
    max-width: 100%; 
 
} 
 

 

 

 
/************************ 
 
HEADING 
 
************************/ 
 

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

 
h1 { 
 
    font-family: 'Oswald', sans-serif; 
 
    margin: 15px 0; 
 
    font-size: 2em; 
 
    font-weight: normal; 
 
    line-height: 0.8em; 
 
} 
 

 
h2 { 
 
    font-size: 0.75em; 
 
    margin: -5px 0 0; 
 
    font-weight: normal; 
 
} 
 

 

 

 
/************************ 
 
NAVIGATION 
 
************************/ 
 

 
nav { 
 
    text-align: center; 
 
    padding: 10px 0; 
 
    margin: 20px 0 0; 
 
} 
 

 

 

 
/************************ 
 
FOOTER 
 
************************/ 
 

 
footer { 
 
    font-size: 0.75em; 
 
    text-align: center; 
 
    clear: both; 
 
    padding-top: 50px; 
 
    color: #ccc; 
 
} 
 

 

 

 
/************************ 
 
PAGE: PORTFOLIO 
 
************************/ 
 

 
#gallery { 
 
    margin: 0; 
 
    padding: 0; 
 
    list-style: none; 
 
    overflow: hidden; 
 
} 
 

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

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

 

 
/************************ 
 
COLORS 
 
************************/ 
 

 
/* site body */ 
 
body{ 
 
    background-color: #fff; 
 
    color: #b3b3b3; 
 
} 
 

 
/* pink header */ 
 
header{ 
 
    border-color: #ffb3ff; 
 
    background: #000000; 
 
} 
 

 
/* nav background on mobile */ 
 
nav{ 
 
    background: #ffb3ff; 
 
} 
 

 
/* logo text */ 
 
h1, h2 { 
 
    color: #fff; 
 
} 
 

 
/* links */ 
 
a { 
 
    color: #00ffb3; 
 
} 
 

 
/* nav links */ 
 
nav a, nav a:visited { 
 
    color: #000; 
 
} 
 

 
/* selected nav link */ 
 
nav a.selected, nav a:hover { 
 
    color: #b300b3 
 
}
<header> 
 
     <a href="index.html" id = "logo"> 
 
     <h1>Carter Goff</h1> 
 
     <h2>Choreographer</h2> 
 
     </a> 
 
     <nav> 
 
     <ul> 
 
      <li><a href="index.html">Home</a></li> 
 
      <li><a href="portfolio.html" class="selected">Portfolio</a></li> 
 
      <li><a href="about.html">About</a></li> 
 
      <li><a href="contact.html">Contact</a></li> 
 
     </ul> 
 
     </nav> 
 
    </header> 
 
    <div id="wrapper"> 
 
     <section> 
 
     <ul id = "gallery"> 
 
      <li> 
 
      <a href="vid/vid1.mp4"> 
 
       <video controls> 
 
       <source src="vid/vid1.mp4" type="video/mp4"> 
 
       Your browser does not support the video tag. 
 
       </video> 
 
      </a> 
 
      </li> 
 
      <li> 
 
      <a href="vid/vid1.mp4"> 
 
       <video controls> 
 
       <source src="vid/vid1.mp4" type="video/mp4"> 
 
       Your browser does not support the video tag. 
 
       </video> 
 
      </a> 
 
      </li> 
 
     </ul> 
 
     </section> 
 
     <footer> 
 
     <a href="http://instagram.com/cartergoffofficial"><img src="img/instagram.png" alt="Instagram Logo"></a> 
 
     <a href="https://www.facebook.com/carter.goff.52"><img src="img/facebook.png" alt ="Facebook Logo"></a> 
 
     <p>&copy; 2016 Carter Goff</p> 
 
     </footer> 
 
    </div>

PS:我冒昧地添加overflow: hidden;#gallery來清除浮動。

PS2:我通過w3c驗證程序運行了您的代碼,以檢查是否缺少結束標籤。這是一個不錯的工具,幫助了很多,習慣使用它:https://validator.w3.org/#validate_by_input。它也提供建議,例如您的section s缺少標題。

相關問題