2017-06-23 50 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給你 –