gpt4 book ai didi

CSS链接背景颜色宽度

转载 作者:太空宇宙 更新时间:2023-11-03 23:58:07 24 4
gpt4 key购买 nike

如何在 li 元素内设置一个链接,使其背景比实际文本长,并且它们彼此齐平?

Example

CSS

.popoutsidebar li { margin-bottom: 20px; padding: 5px; }
.popoutsidebar li a { background-color: #E5E5E5; color: #B94A48; padding: 10px; border-radius: 5px; }
.popoutsidebar li a:hover { background-color: #B94A48; color: #FFFFFF; text-decoration: none; }

最佳答案

<a>默认情况下, anchor 标记是内联的。尝试这样的事情:

.popoutsidebar li a { display:block }

display属性可让您定义特定 HTML 元素的显示方式。

display: block means that the element is displayed as a block, as paragraphs and headers have always been. A block has some whitespaceabove and below it and tolerates no HTML elements next to it, exceptwhen ordered otherwise (by adding a float declaration to anotherelement, for instance).

display: inline means that the element is displayed inline, inside the current block on the same line. Only when it's between two blocksdoes the element form an 'anonymous block', that however has thesmallest possible width.

http://quirksmode.org/css/css2/display.html

关于CSS链接背景颜色宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17930653/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com