相关疑难解决方法(0)

是应该在img标签高度/宽度属性还是在CSS中定义图像大小?

img标签widthheight属性中定义图像大小是更好的编码实践吗?

<img src="images/academia_vs_business.png" width="740" height="382" alt="" />
Run Code Online (Sandbox Code Playgroud)

或者在宽度/高度的CSS样式中?

<img src="images/academia_vs_business.png" style="width:740px; height:382px;" alt="" />
Run Code Online (Sandbox Code Playgroud)

或两者?

<img src="images/academia_vs_business.png" width="740" height="382" style="width:740px; height:382px" alt="" />
Run Code Online (Sandbox Code Playgroud)

html css image

101
推荐指数
5
解决办法
16万
查看次数

HTML和CSS的宽度属性有什么区别?

代码可以在这里找到:

http://www.w3schools.com/css/tryit.asp?filename=trycss_float_elements

<!DOCTYPE html>
<html>
<head>
<style>
.thumbnail 
{
float:left;
width:110px;
height:90px;
margin:5px;
}
</style>
</head>

<body>
<h3>Image Gallery</h3>
<p>Try resizing the window to see what happens when the images do not have enough room.</p>
<img class="thumbnail" src="klematis_small.jpg" width="107" height="90">
<img class="thumbnail" src="klematis2_small.jpg" width="107" height="80">
<img class="thumbnail" src="klematis3_small.jpg" width="116" height="90">
<img class="thumbnail" src="klematis4_small.jpg" width="120" height="90">
<img class="thumbnail" src="klematis_small.jpg" width="107" height="90">
<img class="thumbnail" src="klematis2_small.jpg" width="107" height="80">
<img class="thumbnail" src="klematis3_small.jpg" width="116" height="90">
<img class="thumbnail" src="klematis4_small.jpg" width="120" height="90">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我发现标签width:110px;内有 …

html javascript css

6
推荐指数
2
解决办法
3857
查看次数

标签 统计

css ×2

html ×2

image ×1

javascript ×1