开发者

How to Control Width of Title (H2) with CSS?

开发者 https://www.devze.com 2023-03-07 22:41 出处:网络
I\'ve tried the CSS below. All of the other specifications are working except the width. You can see an example of thebeing too wide here if you need to.

I've tried the CSS below. All of the other specifications are working except the width. You can see an example of the being too wide here if you need to.

Thanks for your help - Tara

.title h2 {
margin:10px 0 0 0;
width:780px;
font-family: HarabaraHandItal开发者_Python百科ic;
font-size: 30px;
padding: 0 0 0 15px;
color:#000;

}


The width you're using is too wide. Try to make the width 750px for example. You'll see that it works fine!

Keep in mind that the padding will be added to the width of the element. In your case the h2 element is 780px (width) + 15px (padding-left) = 795px.


It is working fine here.

I suspect you are being confused about what width means. The property describes the content width. The padding (15px) and borders (0px) and margin (0) all appear around the width.

The container is only 670px wide anyway, so you probably don't want something that is 795px across (width plus padding) inside it.


You need to reduce both the "width" and the "font-size" to make it fit.

Or, if the font-size needs to stay the same, you need to reduce the amount of copy.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号