-1
我正在設計一個在社交網站上使用的佈局。該網站允許使用CSS/HTML元素。在我的設計中,我的兩個堆疊divs之間存在差距。我的代碼沒有差距,所以我不明白爲什麼它在那裏。劃分之間的差距 - 不理解它爲什麼存在
下面是截圖:標題圖片和菜單之間的黑色空格是空格。
這裏是我的HTML:
<!DOCTYPE HTML>
<head>
<link rel="stylesheet" href="vfErin.css">
</head>
<html>
<body>
<div id="customProfile">
<div id="customHeader">
<img src="http://assets.jollyrogerpcs.com/vampirefreaks/axel/cover.png" width="100%">
</div>
<div id="customMenu">
<a href="#">VF Home</a>
<a href="#">Gallery</a>
<a href="#">Journal</a>
<a href="#">Add Me</a>
<a href="#">Rate & Comment</a>
</div>
</div>
</body>
</html>
我的CSS:
/*
#67C8FF neon-blue
#83F52C neon-green
*/
* {
padding: 0;
margin: 0;
text-decoration: none;
border: none;
outline: none;
list-style: none;
transition: all 0.5s;
}
body {
background-color: #000;
text-align: center;
}
#customProfile {
width: 900px;
margin: 0 auto;
text-align: left;
border-left: 1px solid #67C8FF;
border-right: 1px solid #67C8FF;
}
#customMenu {
width: 900px;
font-size: 0pt;
}
#customMenu a:link, #customMenu a:visited {
display: inline-block;
width: 20%;
text-align: center;
background-color: #67c8ff;
font-size: 14pt;
height: 30px;
line-height: 30px;
}
奇數解決方案,因爲在img是一個div應該自動成爲塊元件,如果我沒有弄錯的內部。也許我錯過了我的代碼中的東西。 –
而不是img上的類,你可以使用上下文:'#customHeader img {display:block; }' – connexo
你是對的,div是塊元素,但圖像仍然是塊元素內部的內嵌塊。它不會繼承其父項的塊屬性,因此您必須強制它成爲塊。 – gautsch