2017-03-24 8 views
2

先頭余白<p><div>から出ています。これは、下のスニペットで分かるように、2つのdivの間にスペースを作成します。青色のdivは、緑色のdivの後に開始する必要があります。このスペースを削除する方法。余分なスペースを取っているpタグの上端

#dslc-module-6dbe075eac8 h1 { 
 
    background-color: green; 
 
    border-top-left-radius: 3px; 
 
    border-top-right-radius: 3px; 
 
    border-bottom-left-radius: 0px; 
 
    border-bottom-right-radius: 0px; 
 
    margin-bottom: 0px; 
 
    min-height: 0px; 
 
} 
 

 
#dslc-module-a2d37913705 .dslc-tp-content { 
 
    background-color: blue; 
 
}
<div class="dslc-modules-area dslc-col dslc-12-col dslc-last-col" data-size="12"> 
 
    <div id="dslc-module-6dbe075eac8" class="dslc-module-front dslc-module-DSLC_TP_Title dslc-in-viewport-check dslc-in-viewport-anim-none dslc-col dslc-12-col dslc-last-col dslc-module-handle-like-regular dslc-in-viewport" data-module-id="6dbe075eac8" 
 
    data-dslc-module-id="DSLC_TP_Title" data-dslc-module-size="12" data-dslc-anim="none" data-dslc-anim-delay="0" data-dslc-anim-duration="650" data-dslc-anim-easing="ease" data-dslc-preset="none" style="animation: forwards 0.65s ease none;"> 
 
    <div class="dslc-tp-title"> 
 
     <h1>Difference between StringBuffer and StringBuilder</h1> 
 
    </div> 
 
    </div> 
 
    <!-- .dslc-module --> 
 
</div> 
 
<div id="dslc-module-a2d37913705"> 
 
    <div class="dslc-tp-content"> 
 
    <div id="dslc-theme-content"> 
 
     <div id="dslc-theme-content-inner"> 
 
     <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
 
      It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with 
 
      desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
     </p> 
 
     </div> 
 
    </div> 
 
    </div> 
 

 
</div>

+0

は、pタグの上マージンを削除し、パディングトップを追加し、必要に応じて –

+0

シンプル削除このようなpのマージン: 'p {margin:0 0 1em;}' –

+0

@mukeshとSimrandepに感謝します。これはうまくいくが、なぜこれが起こっているのだろうか。 divとpはブロックレベルの要素です。 – aje

答えて

1

私はあなたのコードを編集しました。 pタグにクラス名を指定して、パディングとマージンを削除するだけです。

#dslc-module-6dbe075eac8 h1 { 
 
    background-color: green; 
 
    border-top-left-radius: 3px; 
 
    border-top-right-radius: 3px; 
 
    border-bottom-left-radius: 0px; 
 
    border-bottom-right-radius: 0px; 
 
    margin-bottom: 0px; 
 
    min-height: 0px; 
 
} 
 

 
#dslc-module-a2d37913705 .dslc-tp-content { 
 
    background-color: blue; 
 
} 
 

 
p { 
 
    margin: 0; 
 
    padding: 0; 
 
}
<div class="dslc-modules-area dslc-col dslc-12-col dslc-last-col" data-size="12"> 
 
    <div id="dslc-module-6dbe075eac8" class="dslc-module-front dslc-module-DSLC_TP_Title dslc-in-viewport-check dslc-in-viewport-anim-none dslc-col dslc-12-col dslc-last-col dslc-module-handle-like-regular dslc-in-viewport" data-module-id="6dbe075eac8" 
 
    data-dslc-module-id="DSLC_TP_Title" data-dslc-module-size="12" data-dslc-anim="none" data-dslc-anim-delay="0" data-dslc-anim-duration="650" data-dslc-anim-easing="ease" data-dslc-preset="none" style="animation: forwards 0.65s ease none;"> 
 

 

 

 

 
    <div class="dslc-tp-title"> 
 
     <h1>Difference between StringBuffer and StringBuilder</h1> 
 
    </div> 
 

 

 

 
    </div> 
 
    <!-- .dslc-module --> 
 
</div> 
 
<div id="dslc-module-a2d37913705"> 
 

 

 

 
    <div class="dslc-tp-content"> 
 
    <div id="dslc-theme-content"> 
 
     <div id="dslc-theme-content-inner"> 
 
     <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
 
      It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with 
 
      desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 

 
     </p> 
 

 
     </div> 
 
    </div> 
 
    </div> 
 

 
</div>

1

だけmargin:0 and padding:0を追加します。このよう

p { 
    margin: 0; 
    padding: 0; 
} 

更新スニペット:

#dslc-module-6dbe075eac8 h1 { 
 
    background-color: green; 
 
    border-top-left-radius: 3px; 
 
    border-top-right-radius: 3px; 
 
    border-bottom-left-radius: 0px; 
 
    border-bottom-right-radius: 0px; 
 
    margin-bottom: 0px; 
 
    min-height: 0px; 
 
} 
 

 
#dslc-module-a2d37913705 .dslc-tp-content { 
 
    background-color: blue; 
 
} 
 

 
p { 
 
    margin: 0; 
 
    padding: 0; 
 
}
<div class="dslc-modules-area dslc-col dslc-12-col dslc-last-col" data-size="12"> 
 
    <div id="dslc-module-6dbe075eac8" class="dslc-module-front dslc-module-DSLC_TP_Title dslc-in-viewport-check dslc-in-viewport-anim-none dslc-col dslc-12-col dslc-last-col dslc-module-handle-like-regular dslc-in-viewport" data-module-id="6dbe075eac8" 
 
    data-dslc-module-id="DSLC_TP_Title" data-dslc-module-size="12" data-dslc-anim="none" data-dslc-anim-delay="0" data-dslc-anim-duration="650" data-dslc-anim-easing="ease" data-dslc-preset="none" style="animation: forwards 0.65s ease none;"> 
 

 

 

 

 
    <div class="dslc-tp-title"> 
 
     <h1>Difference between StringBuffer and StringBuilder</h1> 
 
    </div> 
 

 

 

 
    </div> 
 
    <!-- .dslc-module --> 
 
</div> 
 
<div id="dslc-module-a2d37913705"> 
 

 

 

 
    <div class="dslc-tp-content"> 
 
    <div id="dslc-theme-content"> 
 
     <div id="dslc-theme-content-inner"> 
 
     <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
 
      It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with 
 
      desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 

 
     </p> 
 

 
     </div> 
 
    </div> 
 
    </div> 
 

 
</div>

0
.dslc-theme-content-inner p { 
    margin:0px; 
} 
関連する問題