2017-06-23 47 views
0

我想将我的文本放在网页的某个部分,但是当我将left: 0px;更改为left: 130px;时,它会创建出现水平条的像素。任何想法如何解决这个问题?HTML/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

<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;

enter image description here

left: 0px;

enter image description here

回答

0

只是删除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>

+0

@ user1775718这也有效! +1也给你 –

0

水平杆由内容超越它的父的宽度而引起的。在这里,您已将012px130px移至右侧,这会将其推到其父级的宽度之外。你需要(a)可能使用填充,而不是绝对位置,或者(b)减小宽度,直到这种情况不发生。

+0

我用宽度:90%减少的宽度和水平条消失了。非常感谢! +1给你 –