您现在的位置是:首页 > 电脑 > 

无法通过样式表在html代码中设置元素大小的大小(Can't set size of size of element in html code—only through stylesheet)

2025-07-26 09:42:56
无法通过样式表在html代码中设置元素大小的大小(Can't set size of size of element in html code—only through stylesheet) 对不起,如果之前已经回答过,但我无法在任何地方到它。 我正在尝试创建一种缩略图库但我无法在html代码中设置元素的宽度和高度。 出于某种原因,如果我在样式表中设置
无法通过样式表在html代码中设置元素大小的大小(Can't set size of size of element in html code—only through stylesheet)

对不起,如果之前已经回答过,但我无法在任何地方到它。

我正在尝试创建一种缩略图库但我无法在html代码中设置元素的宽度和高度。 出于某种原因,如果我在样式表中设置大小,但在代码本身中没有设置大小。 我一直试图弄清楚这一点,这让我疯了。 我希望这很简单,我误解了。 任何帮助将不胜感激。 这是一个示例链接:

http:///4gupR/1/

CSS

.box { display: block; float: left; margin: 0 20px 20px 0; } figure { position: relative; margin: 0; padding: 0; display: block; }

HTML

<div class="box"> <figure width="800" height="800"> <img src="http://placehold.it/400x00"> </figure> <figcaption>Caption</figcaption> </div>

只是为了澄清,重要的是我通过HTML代码执行此操作,而且,我需要设置大小,而不仅仅是使用边距或填充...

一如既往,非常感谢您提供的任何帮助!

sorry if this has been answered before, but I haven't been able to find it anywhere.

I am trying to create a sort of thumbnail gallery but I am having trouble setting the width and heights of elements in the html code. For some reason it works if I set the size in the stylesheet, but not in the code itself. I have been trying to figure this out all night and it's driving me nuts. I'm hoping it's something simple that I am misunderstanding. Any help would be greatly appreciated. Here's a link to a sample:

http:///4gupR/1/

CSS

.box { display: block; float: left; margin: 0 20px 20px 0; } figure { position: relative; margin: 0; padding: 0; display: block; }

HTML

<div class="box"> <figure width="800" height="800"> <img src="http://placehold.it/400x00"> </figure> <figcaption>Caption</figcaption> </div>

Just to clarify, it is important that I do this through the html code, and also, I need to set the size, and not just use margin, or padding…

As always, thanks so much for any help you can offer!

最满意答案

如果要使用内联样式,则必须使用“样式”属性。

<div style="property: value;">

http:///bZkYS/1/

When you want to use inline styles, you have to use the "style" attribute.

<div style="property: value;">

http:///bZkYS/1/

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/697394.html

相关标签:无
上传时间: 2023-08-27 09:52:53
留言与评论(共有 5 条评论)
本站网友 花隐怀石料理
6分钟前 发表
我希望这很简单
本站网友 激光红血丝
5分钟前 发表
我正在尝试创建一种缩略图库但我无法在html代码中设置元素的宽度和高度
本站网友 南通科技投资集团股份有限公司
2分钟前 发表
则必须使用“样式”属性
本站网友 张女士
16分钟前 发表
0 20px 20px 0; } figure { position