[英]html/css max-width not working
So I have a tooltip on tumblr and everything about the code is working except the max width, it's stuck at 75px. 因此,我在tumblr上有一个工具提示,关于代码的所有内容都可以正常工作,但最大宽度除外,它停留在75px。 I've changed it to 250px and 300px and it refuses to stretch with the words in the tooltip.
我将其更改为250px和300px,并且拒绝使用工具提示中的文字进行拉伸。
Code: 码:
a[tooltip]:hover:after { position: absolute; z-index: 99999999; max-width: 300px; min-width: 60px; border: 1px solid #bababa; padding: 6px; margin: -27px 0px 0px 28px; background-color: #ffffff; color: #1a2242; font-family: arial; font-size: 7px; line-height: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: none; text-align: center; box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px; opacity: 1; content: attr(tooltip); transition-duration: 0.6s; -moz-transition-duration: 0.6s; -webkit-transition-duration: 0.6s; -o-transition-duration: 0.6s; } #smt-tooltip { position: absolute; z-index: 99999999; max-width: 300px; min-width: 60px; border: 1px solid #bababa; padding: 6px; margin: -27px 0px 0px 28px; background-color: #ffffff; color: #1a2242; font-family: arial; font-size: 7px; line-height: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: none; text-align: center; box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px; opacity: 1; outline: 0px solid #ddd; -moz-transition-duration: 0.3s; -webkit-transition-duration: 0.3s; -o-transition-duration: 0.3s; }
<a href="#popup3" tooltip="words">Link</a>
Any help is appreciated and if you need more information, let me know. 感谢您的帮助,如果您需要更多信息,请告诉我。
add width: 100%;
增加
width: 100%;
for your pseudo element, also you can use box-sizing
so that the width and height properties set the dimensions of the content rather than the content. 对于伪元素,还可以使用
box-sizing
以便width和height属性设置内容的尺寸,而不是内容的尺寸。 ` `
a[tooltip]:hover:after { width: 100%; box-sizing: border-box; position: absolute; z-index: 99999999; max-width: 300px; min-width: 60px; border: 1px solid #bababa; padding: 6px; margin: -5px 0 0 28px; background-color: #ffffff; color: #1a2242; font-family: arial; font-size: 7px; line-height: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: none; text-align: center; box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px; opacity: 1; content: attr(tooltip); transition-duration: 0.6s; -moz-transition-duration: 0.6s; -webkit-transition-duration: 0.6s; -o-transition-duration: 0.6s; } #smt-tooltip { position: absolute; z-index: 99999999; width: 300px; max-width: 200px; min-width: 60px; border: 1px solid #bababa; padding: 6px; margin: -27 0 0 28px; background-color: #ffffff; color: #1a2242; font-family: arial; font-size: 7px; line-height: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: none; text-align: center; box-shadow: rgba(0, 0, 0, 0.04)0 2px 4px; opacity: 1; outline: 0px solid #ddd; -moz-transition-duration: 0.3s; -webkit-transition-duration: 0.3s; -o-transition-duration: 0.3s; }
<a href="#popup3" tooltip="words hooha haooo ahhahhhah ahahhahhah ahahhahaha hahahhahha ahahahhahha ahahhaha">Link</a>
The reason it's not working is because you have a width:100%
set on the a:after
pseudo-element. 它不起作用的原因是因为您在
a:after
伪元素上设置了width:100%
。 That property will set the width of the element to that of it's parent, in this case your a
is a child of your <div class="markericon1">
. 该属性会将元素的宽度设置为其父元素的宽度,在这种情况下,
a
是您的<div class="markericon1">
的子元素。 You can see that if you change just the width of <div class="markericon1">
to something higher you will get the result you want. 您会看到,如果仅将
<div class="markericon1">
的宽度更改为更大的宽度,则将获得所需的结果。
.markericon1 {
width:300px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.