2016-11-12 1 views
1


내 HTML에는 뷰포트의 높이에 걸쳐 몸체가 펼쳐져 있고 뷰포트에는 텍스트 단락이 들어있는 div가 있습니다. 내 텍스트는 약간의 여백이 있으며, 그 때문에 텍스트가 본문을 초과합니다.
문단이 본문의 자식 인 div의 자식 이었기 때문에 단락의 여백이 부모를 초과 했으므로 정말 이상하다고 생각했습니다. 이것에 대한 해결책이 있습니까? (내가 남기고 싶은 마진을 제외하고)
미리 감사드립니다!

Picture
이것은 당신은이 페이지의 상단에 도달하지 명확하게 볼 오른쪽에있는 Inspector에서 선택된으로 푸른 물건 (실제로 몸

내 물건 :..HTML 텍스트 여백이 본문을 초과합니다

@font-face { 
 
    font-family: "MavenPro"; 
 
    src: url('fonts/MavenPro-Medium.ttf'); 
 
} 
 

 
@font-face { 
 
    font-family: "MavenPro"; 
 
    src: url('fonts/MavenPro-Bold.ttf'); 
 
    font-weight: bold; 
 
} 
 

 
* { 
 
    box-sizing: border-box; 
 
} 
 

 
html, body { 
 
    height: 100%; 
 
    min-height: 100%; 
 
    margin: 0; 
 
    font-family: "MavenPro"; 
 
    background-image: url('../images/BIER.jpeg'); 
 
    background-color: white; 
 
    background-size: cover; 
 
    background-position: center; 
 
} 
 

 
p { 
 
    margin: 10px; 
 
} 
 

 
#nav { 
 
    position: relative; 
 
    width: auto; 
 
    float: left; 
 
    top: 0; 
 
    padding: 0; 
 
    height: auto; 
 
    height: 100%; 
 
} 
 

 
#menu { 
 
    list-style-type: none; 
 
    padding: 10px; 
 
    margin: 10px 5px; 
 
    display: inline-block; 
 
    box-sizing: border-box; 
 
} 
 

 
.mitem { 
 
    -webkit-transition-duration: 0.2s; 
 
    background-color: #dea243; 
 
    border-radius: 20px; 
 
    padding: 10px; 
 
    padding-left: 15px; 
 
    padding-right: 35px; 
 
    margin: 15px 5px; 
 
    font-size: 20px; 
 
    font-weight: bold; 
 
    color: #ae4411; 
 
} 
 

 
.mitem:link { 
 
    /*no css yet*/ 
 
} 
 

 
.mitem:hover { 
 
    -webkit-transition-duration: 0.2s; 
 
    background-color: #d2b651; 
 
    color: #cccccc; 
 
    padding-left: 25px; 
 
    padding-right: 25px; 
 
} 
 

 
.mitem:active { 
 
    -webkit-transition-duration: 0.1s; 
 
    padding-left: 30px; 
 
    padding-right: 20px; 
 
    background-color: #ee7744; 
 
} 
 

 
a:link, a:visited { 
 
    text-decoration: none; 
 
    color: #0025ff; 
 
    -webkit-transition-duration: 0.2s; 
 
} 
 

 
a:hover { 
 
    -webkit-transition-duration: 0.2s; 
 
    color: #0045ff; 
 
} 
 

 
a:active { 
 
    -webkit-transition-duration: 0.2s; 
 
    color: #ff4444; 
 
} 
 

 
#content { 
 
    /*no css yet*/ 
 
}
<!DOCTYPE html> 
 
    <head> 
 
    <link rel="stylesheet" href="css/mainstyle.css"> 
 
    </head> 
 
    <body> 
 
    <div id="nav"> 
 
    <ul id="menu"> 
 
    <a href="#link"><li class="mitem">Home</li></a> 
 
    <a href="#link"><li class="mitem">Alcohol</li></a> 
 
    </ul> 
 
    </div> 
 
    <div id="content"> 
 
    <p>paragraph</p> 
 
    <p><a href="#link">Here is a link</a> 
 
    </div> 
 
    </body> 
 
</html>

+2

코드 공유 ... – Pranjal

답변

0

당신의 단락 요소 및 본문 요소의 CSS에 width: 100%;를 추가합니다.

이렇게하면 본문 내부의 단락 요소를 집어 넣습니다.

+0

죄송합니다. 저에게 도움이되지 않습니다. 위에서 내 코드를 참조하십시오. –

+0

'#content'에 'display : inline-block'을 추가하십시오. 문제 해결됨. 첫 번째 p 요소를 아래로 이동해야하는 경우 먼저
을 입력하고 br의 패딩 및 마진을 원하는대로 사용자 정의하십시오. 여기에 : codepen.io/shreyansjain33/pen/ENyLrL – shreyansjain33

0

수정/추가 :

이유는 당신의 p 태그 - 그것은 여백 설정 (10px)이다. 당신이 추가하면, 공간 위에서 사라 :

p:first-of-type { 
    margin-top: 0; 
} 

http://codepen.io/anon/pen/jVqMBV

관련이없는 참고 : li 요소 a 태그 내부는 둥근 다른 방법이어야한다해서는 안됩니다.

+0

도움을 주셔서 감사합니다.하지만 슬프게도, 이것도 효과가 없었습니다. 신체 위의 공간은 작아졌지만 여전히 사라지지 않았습니다. 어디서 추가해야하는지 모르겠다.하지만 html, body, p, #content (그 p는 자식이다.)에 추가하려고했다. –

+0

'*'은 범용 선택 자다 : 만약 당신이 그것을 쓸 수 있다면 필자가 작성한대로 * all * 요소에 유효합니다. – Johannes

+0

또한 "body"및 "html"에 "margin : 0"이 있으면 "body above space"가 없어야합니다. 사실 당신이 말하는 것에 대해 확실하지 않습니다. 실제 코드를 게시해야합니다 (게시 한 작은 코드는 귀하가 묘사 한 것을 분명히 보여줄 수 없습니다). – Johannes

관련 문제