简体   繁体   English

HTML / CSS上的额外像素

[英]Extra Pixels on HTML/CSS

I want to place my text on a certain part of the web page but when I change left: 0px; 我想将文本放置在网页的某个部分,但是当我left: 0px;更改时left: 0px; to left: 130px; left: 130px; it creates pixels that results in a horizontal bar appearing. 它创建像素,导致出现水平条。 Any idea on how can I fix this? 关于如何解决此问题的任何想法?

CSS CSS

.main4{
text-align: left;
left: 0px;
line-height: 70px;
margin-top: -30px;
position: absolute;
top: 8px;
width: 98.7%;
font-family: "Times New Roman", Times, serif;
font-size: 18px;
margin-bottom: 0px;
display: block;
}

HTML HTML

<div class="main4">
<h1>Upon Doctor's advice</h1>
<h1>Upon advice by family, friends, relatives, another previous patient</h1>
<h1>Recommended by hospital employee</h1>
<h1>Employee's hospital privilege</h1>
<h1>Reputation as the center of best doctors</h1>
<h1>Recommended for good nursing care</h1>
<h1>Others (Please specify): </h1>
</div>

left: 130px;

在此处输入图片说明

left: 0px;

在此处输入图片说明

The horizontal bar is caused by content going beyond the width of its parent. 水平条是由超出其父级宽度的内容引起的。 Here you've moved .main4 130px to the right, that will have pushed it outside the width of its parent. 在这里,您已将.main4向右移动.main4 ,这会将其推到其父级的宽度之外。 You need to (a) probably use padding, not position absolute, or (b) decrease the width of .main4 until this doesn't happen. 您需要(a)可能使用填充,而不是绝对位置,或(b)减小.main4的宽度,直到这没有发生。

Just remove width: 98.7%; 只需移除width: 98.7%;

 .main4{ text-align: left; left: 130px; line-height: 70px; margin-top: -30px; position: absolute; top: 8px; font-family: "Times New Roman", Times, serif; font-size: 18px; margin-bottom: 0px; display: block; } 
 <div class="main4"> <h1>Upon Doctor's advice</h1> <h1>Upon advice by family, friends, relatives, another previous patient</h1> <h1>Recommended by hospital employee</h1> <h1>Employee's hospital privilege</h1> <h1>Reputation as the center of best doctors</h1> <h1>Recommended for good nursing care</h1> <h1>Others (Please specify): </h1> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM