我是一個初學HTML5和CSS。我在float中遇到了一個問題:left。我想將數字顯示在前一個的右側,但它不起作用。 我試過尋找一些SO問題,但還沒有找到確切的答案。這將是巨大的,如果你能幫助浮動:在課堂上留下不工作的數字標記
的代碼位於: http://jsfiddle.net/ECs4g/
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link
rel="stylesheet"
href="drop.css"
>
</head>
<body>
<section id="pics">
<figure
id="pic1"
class="pictures"
>
<img
alt="figure1"
src="http://b-i.forbesimg.com/kellyclay/files/2013/12/glass.jpg"
title="pic1"
>
</figure>
<figure
id="pic2"
class="pictures"
>
<img
alt="figure2"
src="http://glass-apps.org/wp-content/uploads/2013/06/google-glass1.jpg"
title="pic2"
>
</figure>
</section>
</body>
</html>
CSS:
#pics{
width:200px;
height:200px;
}
.pictures{
float: left;
}
.pictures img{
width:100%;
height:auto;
}
還要注意的是'figure'元素可能有一些默認的樣式,這將影響佈局。 – Palpatim
我已經將'200px'分配給'pics',因爲我想'section'使用我定義的空間。但是,使用您的解決方案也有可能嗎? – GodMan
好吧,你不能同時擁有兩個圖像,並且圖像相鄰並且是一個狹窄的容器。也就是說,如果你真的需要這個(小於100px),你需要在'.pictures'上設置一個較小的'width'。 – Boldewyn