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

编程入门 行业动态 更新时间:2024-10-25 02:30:14
无法通过样式表在html代码中设置元素大小的大小(Can't set size of size of element in html code—only through stylesheet)

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

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

http://jsfiddle.net/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/400x300"> </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://jsfiddle.net/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/400x300"> </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://jsfiddle.net/bZkYS/1/

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

<div style="property: value;">

http://jsfiddle.net/bZkYS/1/

更多推荐

本文发布于:2023-08-06 21:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455006.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   样式表   元素   代码   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!