Gecko 与 Webkit:内联块内的填充

发布于 2024-12-17 10:51:37 字数 285 浏览 4 评论 0原文

这是显示我的问题的小提琴: http://jsfiddle.net/7QaXL/1/

在 webkit 中基于浏览器的

的填充似乎将图像向上推,这不是我想要的。

所以我的问题是:

  • 什么是正确的行为(根据规范)?
  • 如何获得六个相同高度的块,内部元素带有填充,而不改变它们的对齐方式?

Here's the fiddle showing my problem: http://jsfiddle.net/7QaXL/1/

In the webkit-based browsers the padding of the <p>s seem to push the images up, which is not what I want.

So my questions are:

  • What is the correct behavior (according to the specs)?
  • How can I get six blocks of the same height, with inside elements with padding, without changing their alignments?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天的雪花 2024-12-24 10:51:37

首先,我无法复制你的问题。其次,我会尝试使用这样的东西:

<ul>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 1</h6>
                <p>Long description 1</p>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 2</h6>
                <p>Long description 2</p>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 3</h6>
                <p>Long description 3</p>
            </figcaption>
        </figure>
    </li>
</ul>

这在语义上更有意义,因为现在细节与相关图像相关联,并且此标记将允许您更好地控制样式。 figurefigcaption 是 HTML5 元素,如果您需要任何进一步的帮助,请告诉我!

编辑:经过进一步探索这个问题,我发现您遇到的问题(据我所知)与 display: inline-block; 及其自然行为有关。如果您用 float: left; 替换该属性并给出无序列表 overflow: hide; (或使用clearfix 技术),问题应该得到解决。

Firstly, I can't replicate your problem. Secondly, I would try using something like this:

<ul>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 1</h6>
                <p>Long description 1</p>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 2</h6>
                <p>Long description 2</p>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="http://wiki.urbandead.com/images/thumb/6/6a/Img_upld.gif/100px-Img_upld.gif" alt="">
            <figcaption>
                <h6>Title 3</h6>
                <p>Long description 3</p>
            </figcaption>
        </figure>
    </li>
</ul>

This makes much more sense semantically as now the details are tied to the relevant images, and this markup will allow you to have greater control over the styling. figure and figcaption are HTML5 elements, if you need any further help just let me know!

EDIT: Upon further exploration of the issue I have discovered that the issue you are encountering (as far as I can tell) is to do with display: inline-block; and its natural behaviour. If you replace that property with float: left; and give the unordered list overflow: hidden; (or use a clearfix technique) the problem should be resolved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文