我做了一個網站,其中顯示主div,多個div(作爲內聯元素),這些div包含IMG和P元素。HTML和CSS - 內嵌塊元素的問題
那麼,如果我離開P元素(或沒有p標籤的文本),一切都可以,但是如果我在img之後添加文本,coresponding div將脫離正常位置。
的頁面是在網上http://ace-acid.no-ip.org/acid-game-studios/ (即當前運行的版本)
而這一次的版本與它的問題 - >http://ace-acid.no-ip.org/acid-game-studios-issue/ (在這裏你可以清楚地看到,所有的div都沒有的在它的文字,空間不足......)
我該如何防止這種行爲?
謝謝所有球員的^^
<編輯>
我認爲這是一個問題的CSS(塊元素,inline-block的元素,fextflow,垂直對齊,...),不是嗎?
b.t.w. - >該網站是基於流動網格的網站,因此如果您縮小瀏覽器,它將顯示一個表格和一個移動版本。這個問題似乎只有同一行,文字,因爲下一行,在div塊沒有間隔倒在apear ...
< /編輯>
HTML代碼:
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>aCID Game Studios</title>
<link rel="stylesheet" type="text/css" href="boilerplate.css">
<link rel="stylesheet" type="text/css"href="style.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="respond.min.js"></script>
</head>
<body>
<div class="gridContainer clearfix">
<div id="div_header" align="center">
<div id="div_header_img"></div>
<div id="div_menu" align="center">
<p>< MENU ></p>
</div>
</div>
<div id="div_main" align="center">
<div id="div_page">
<br><br><p>< PAGE ></p><br><br>
<div class="div_game_thumb">
<img style="vertical-align:middle" src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
</div>
<div class="div_game_thumb">
<img src="img/games/GunsOfTheNation.png" onMouseOver="this.src='img/games/GunsOfTheNation_hover.png'" onMouseOut="this.src='img/games/GunsOfTheNation.png'"/>
</div>
<div class="div_game_thumb">
<img src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
</div>
<div class="div_game_thumb">
<img src="img/games/GunsOfTheNation.png" onMouseOver="this.src='img/games/GunsOfTheNation_hover.png'" onMouseOut="this.src='img/games/GunsOfTheNation.png'"/>
</div>
<div class="div_game_thumb">
<img src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
</div>
</div>
</div>
</div>
</body>
</html>
CSS代碼:
@charset "utf-8";
/* Einfache fließende Medien
Hinweis: Für fließende Medien müssen Sie die Attribute 'height' und 'width' des Medium aus dem HTML-Code entfernen
http://www.alistapart.com/articles/fluid-images/
*/
html{
margin: 0;
padding: 0;
border: 0;
}
body {
background-color: #0c0d0f;
color: #3982aa;
}
p {
margin: 0;
padding: 10px;
}
img, object, embed, video {
width: 100%;
}
/* IE 6 unterstützt keine maximale Breite, verwenden Sie daher eine Standardbreite von 100% */
.ie6 img {
width: 100%;
}
.div_game_thumb {
width:320px;
height:350px;
display:inline-block;
border:1px solid #fff;
}
/*
Dreamweaver-Eigenschaften für fließende Raster
----------------------------------
dw-num-cols-mobile: 6;
dw-num-cols-tablet: 8;
dw-num-cols-desktop: 14;
dw-gutter-percentage: 15;
Idee durch den Artikel "Responsive Web Design" von Ethan Marcotte
http://www.alistapart.com/articles/responsive-web-design
und "Golden Grid System" von Joni Korpi
http://goldengridsystem.com/
*/
/* Layout für Mobilgeräte: 480 px oder weniger. */
.gridContainer {
margin-left: auto;
margin-right: auto;
width: 100%;
padding-left: 0;
padding-right: 0;
}
#div_header {
clear: both;
float: left;
margin: 0;
width: 100%;
display: block;
}
#div_header_img {
width: 450px;
height: 150px;
background-color: #999;
background-position: top center;
background-repeat: no-repeat;
background-image: url(img/header_m.png);
}
#div_menu {
width: 450px;
height: 50px;
background-color: #111;
}
#div_main {
clear: both;
float: left;
margin: 0;
width: 100%;
display: block;
min-height: 300px;
}
#div_page {
width: 450px;
min-height: 300px;
background-position: top center;
background-repeat: repeat-x;
background-image: url(img/page_border_top.png);
background-color: #000;
}
/* Layout für Tablet-PCs: 481 bis 768 px. Erbt Stile vom: Layout für Mobilgeräte. */
@media only screen and (min-width: 481px) {
body {
background-position: top center;
background-repeat: repeat;
background-image: url(img/bg.png);
}
#div_header {
clear: both;
float: left;
width: 100%;
display: block;
display: block;
background-position: top center;
background-repeat: repeat-y;
background-image: url(img/page_bg_t.png);
}
#div_header_img {
width: 650px;
height: 150px;
display: block;
background-image: url(img/header_t.png);
}
#div_menu {
width: 650px;
background-position: top center;
background-repeat: no-repeat;
background-image: url(img/menu_bg_t.png);
}
#div_main {
clear: both;
float: left;
margin: 0;
width: 100%;
display: block;
background-position: top center;
background-repeat: repeat-y;
background-image: url(img/page_bg_t.png);
}
#div_page {
width: 650px;
}
}
/* Desktoplayout: 769 bis maximal 1232 px. Erbt Stile von: den Layouts für Mobilgeräte und Tablet-PCs. */
@media only screen and (min-width: 769px) {
#div_header {
clear: both;
float: left;
width: 100%;
display: block;
background-image: url(img/page_bg.png);
}
#div_header_img {
width: 1000px;
height: 200px;
background-image: url(img/header.png);
}
#div_menu {
width: 1000px;
background-position: top center;
background-repeat: no-repeat;
background-image: url(img/menu_bg.png);
}
#div_main {
clear: both;
float: left;
margin: 0;
width: 100%;
display: block;
background-image: url(img/page_bg.png);
}
#div_page {
width: 1000px;
}
}
你真棒! :D謝謝你!你從噩夢中拯救了我^^ – Ace