2017-01-19 6 views
0

スパンと段落の間に水平線を付ける方法はありますか?行の段落と同じ幅にする必要があります。 これをどのようにして実現できますか? divはフレックスアイテムとして認識され、段落の隣に置かれるため、divを使用することはできません。フレックスボックスでスパンと段落の間に水平線を作成する

詳細情報が必要な場合は、私に知らせて。絶対:

rentout.html.erb

<div class="vorteil_wrapper"> 
    <div class="rentout_content_left"> 
     <p class="rentout_paragraph"> 
      <span class="rentout_heading">Erstellung eines professionellen Inserats</span></br> 
      Wir besuchen Ihre Unterkunft und erstellen professionelle Fotos und Videos, 
      welche nach der Bearbeitung für Ihr Inserat auf unserer Internetseite 
      genutzt werden. Darüber hinaus verfassen wir eine hochwertige Beschreibung 
      und Präsentation Ihrer Unterkunft, welche die Highlights sowie die 
      Atmosphäre Ihrer Unterkunft in Vordergrund setzt. 
     </p> 
    </div> 
    <div class="rentout_picture_right"> 
     <%= image_tag("inserat.png", alt: "inserat", :class => "inserat") %> 
    </div> 
</div> 

<div class="vorteil_wrapper_reverse"> 
    <div class="rentout_content_right"> 
     <p class="rentout_paragraph"> 
      <span class="rentout_heading">Responsive Webdesign</span></br> 
      Wussten Sie das 65% aller Internet Nutzer ein Handy zum Surfen benutzen! 
      Ihr zukünftiges Inserat wird auf unserer Seite optimal auf allen Geräten 
      angezeigt, um somit die Benutzerfreundlichkeit und die Umsatzrate zu 
      steigern. 
     </p> 
    </div> 
    <div class="rentout_picture_left"> 
     <%= image_tag("responsive_webdesign.png", alt: "responsive webdesign", :class => "responsive_webdesign") %> 
    </div> 
</div> 

application.scssここ

.vorteil_wrapper { 
    height: 200px; 
    margin-bottom: 0px; 
    display: flex; 
    justify-content: space-around; 
} 

.vorteil_wrapper_reverse { 
    margin-bottom: 30px; 
    display: flex; 
    justify-content: space-around; 
    flex-direction: row-reverse; 
} 

.rentout_content_left { 
    height: 200px; 
    width: 100%; 
    padding-right: 30px; 
    display: flex; 
    align-items: center; 
} 

.rentout_content_right { 
    height: 200px; 
    width: 100%; 
    padding-left: 30px; 
    display: flex; 
    align-items: center; 
} 

.rentout_heading { 
    font: 28px Raleway-Medium, sans-serif; 
    margin-bottom: 6px; 
    display: inline-block; 
    text-decoration: underline; 
    text-decoration-color: red; 
} 

.rentout_paragraph { 
    text-align: justify; 
    font: 18px Raleway-Regular, sans-serif; 
} 

これは、位置の問題を解決しようとしています。問題は、div(rentout_content_left/rentout_content_right)内の要素(段落/スパン)が中央に配置され、各段落とスパンの文字数が異なるため、すべての見出しが異なる高さで開始されることです。

.rentout_wrapper { 
 
    max-width: 1000px; 
 
    width: 100%; 
 
    margin: 0 auto; 
 
} 
 
.vorteil_wrapper { 
 
    height: 200px; 
 
    margin-bottom: 0px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
    position: relative; 
 
} 
 
.vorteil_wrapper_reverse { 
 
    margin-bottom: 30px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
    flex-direction: row-reverse; 
 
} 
 
.rentout_content_left { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-right: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_content_right { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-left: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_heading { 
 
    font: 28px Raleway-Medium, sans-serif; 
 
    margin-bottom: 6px; 
 
    display: inline-block; 
 
} 
 
.rentout_heading::after { 
 
    content: ""; 
 
    position: absolute; 
 
    border-bottom: 1px solid red; 
 
    left: 0; 
 
    bottom: -5px; 
 
    width: 100% 
 
} 
 
.rentout_paragraph { 
 
    text-align: justify; 
 
    font: 18px Raleway-Regular, sans-serif; 
 
}
<div class="rentout_wrapper"> 
 
    <div class="vorteil_wrapper"> 
 
    <div class="rentout_content_left"> 
 
     <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Erstellung eines professionellen Inserats</span> 
 
     </br> 
 
     Wir besuchen Ihre Unterkunft und erstellen professionelle Fotos und Videos, welche nach der Bearbeitung für Ihr Inserat auf unserer Internetseite genutzt werden. Darüber hinaus verfassen wir eine hochwertige Beschreibung und Präsentation Ihrer Unterkunft, 
 
     welche die Highlights sowie die Atmosphäre Ihrer Unterkunft in Vordergrund setzt. 
 
     </p> 
 
    </div> 
 
    <div class="rentout_picture_right"> 
 
     <img src="//lorempixel.com/200/192"> 
 
    </div> 
 
    </div> 
 

 
    <div class="vorteil_wrapper_reverse"> 
 
    <div class="rentout_content_right"> 
 
     <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Responsive Webdesign</span> 
 
     </br> 
 
     Wussten Sie das 65% aller Internet Nutzer ein Handy zum Surfen benutzen! Ihr zukünftiges Inserat wird auf unserer Seite optimal auf allen Geräten angezeigt, um somit die Benutzerfreundlichkeit und die Umsatzrate zu steigern. 
 
     </p> 
 
    </div> 
 
    <div class="rentout_picture_left"> 
 
     <img src="//lorempixel.com/200/192"> 
 
    </div> 
 
    </div> 
 
</div>

enter image description here

+0

<br />を使用します見出しと段落は段落とスパンではありません。あなたはあなたの構造を再フォーマットすることを考えるかもしれません。 –

答えて

1

あなたのspan

に擬似要素::afterを使用することができます</br>が無効である、どちらかあなたは明らかにこれはdiv要素でなければなりません<br><br/>または

.vorteil_wrapper { 
 
    height: 200px; 
 
    margin-bottom: 0px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
} 
 
.vorteil_wrapper_reverse { 
 
    margin-bottom: 30px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
    flex-direction: row-reverse; 
 
} 
 
.rentout_content_left { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-right: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_content_right { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-left: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_heading { 
 
    font: 28px Raleway-Medium, sans-serif; 
 
    margin-bottom: 6px; 
 
    display: block; 
 
    position: relative 
 
} 
 
.rentout_heading::after { 
 
    content: ""; 
 
    position: absolute; 
 
    border-bottom: 1px solid red; 
 
    left: 0; 
 
    bottom: -5px; 
 
    width: 100% 
 
} 
 
.rentout_paragraph { 
 
    text-align: justify; 
 
    font: 18px Raleway-Regular, sans-serif; 
 
}
<div class="vorteil_wrapper"> 
 
    <div class="rentout_content_left"> 
 
    <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Erstellung eines professionellen Inserats</span> 
 
     <br /> 
 
     Wir besuchen Ihre Unterkunft und erstellen professionelle Fotos und Videos, welche nach der Bearbeitung für Ihr Inserat auf unserer Internetseite genutzt werden. Darüber hinaus verfassen wir eine hochwertige Beschreibung und Präsentation Ihrer Unterkunft, 
 
     welche die Highlights sowie die Atmosphäre Ihrer Unterkunft in Vordergrund setzt. 
 
    </p> 
 
    </div> 
 
    <div class="rentout_picture_right"> 
 
    <img src="//lorempixel.com/200/200"> 
 
    </div> 
 
</div> 
 

 
<div class="vorteil_wrapper_reverse"> 
 
    <div class="rentout_content_right"> 
 
    <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Responsive Webdesign</span> 
 
     <br /> 
 
     Wussten Sie das 65% aller Internet Nutzer ein Handy zum Surfen benutzen! Ihr zukünftiges Inserat wird auf unserer Seite optimal auf allen Geräten angezeigt, um somit die Benutzerfreundlichkeit und die Umsatzrate zu steigern. 
 
    </p> 
 
    </div> 
 
    <div class="rentout_picture_left"> 
 
    <img src="//lorempixel.com/200/200"> 
 
    </div> 
 
</div>

+0

実際には
と一緒ですが、なんらかの理由でこれも
と同じように動作します;) お試しいただきありがとうございます。あなたの提案には線が見えません。私は位置とそれを行う必要がある場合:絶対と幅:100%私はまた、ラッパーの位置を相対的にしなければならない場合でも、それはかなり乱雑に見える... – trickydiddy

+0

かなりかわいい??ここでうまくいく。面倒なところ?あなたのスニペットを表示する – dippas

+0

私の質問にスニペットを追加しました;) – trickydiddy

1

あなたはクラス.rentout_heading::afterを使用して、次の解決策を試すことができます:

.vorteil_wrapper { 
 
    height: 200px; 
 
    margin-bottom: 0px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
} 
 
.vorteil_wrapper_reverse { 
 
    margin-bottom: 30px; 
 
    display: flex; 
 
    justify-content: space-around; 
 
    flex-direction: row-reverse; 
 
} 
 
.rentout_content_left { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-right: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_content_right { 
 
    height: 200px; 
 
    width: 100%; 
 
    padding-left: 30px; 
 
    display: flex; 
 
    align-items: center; 
 
} 
 
.rentout_heading { 
 
    font: 28px Raleway-Medium, sans-serif; 
 
    margin-bottom: 6px; 
 
    display: inline-block; 
 
    text-decoration-color: red; 
 
    width:100%; 
 
} 
 
.rentout_heading::after { 
 
    content:""; 
 
    display:block; 
 
    border:1px solid red; 
 
} 
 
.rentout_paragraph { 
 
    text-align: justify; 
 
    font: 18px Raleway-Regular, sans-serif; 
 
}
<div class="vorteil_wrapper"> 
 
    <div class="rentout_content_left"> 
 
    <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Erstellung eines professionellen Inserats</span></br> 
 
    Wir besuchen Ihre Unterkunft und erstellen professionelle Fotos und Videos, 
 
    welche nach der Bearbeitung für Ihr Inserat auf unserer Internetseite 
 
    genutzt werden. Darüber hinaus verfassen wir eine hochwertige Beschreibung 
 
    und Präsentation Ihrer Unterkunft, welche die Highlights sowie die 
 
    Atmosphäre Ihrer Unterkunft in Vordergrund setzt. 
 
    </p> 
 
</div> 
 
<div class="rentout_picture_right"> 
 
    <img src="http://placehold.it/200x200"/> 
 
</div> 
 
</div> 
 

 
<div class="vorteil_wrapper_reverse"> 
 
    <div class="rentout_content_right"> 
 
    <p class="rentout_paragraph"> 
 
     <span class="rentout_heading">Responsive Webdesign</span></br> 
 
    Wussten Sie das 65% aller Internet Nutzer ein Handy zum Surfen benutzen! 
 
    Ihr zukünftiges Inserat wird auf unserer Seite optimal auf allen Geräten 
 
    angezeigt, um somit die Benutzerfreundlichkeit und die Umsatzrate zu 
 
    steigern. 
 
    </p> 
 
</div> 
 
<div class="rentout_picture_left"> 
 
<img src="http://placehold.it/200x200"/> 
 
</div> 
 
</div>

+0

これは実際に私に見出しの下に下線のみを与えます。行に段落の幅がありませんが、試してみていただきありがとうございます。 ;) – trickydiddy

+1

@trickydiddy - 行に段落の幅があります。あなたのコードで 'width:100%'を ''に設定するのを忘れたと思いますか?ここのスニペットを参照してください... –

+0

ええ、あなたは正しいです!お返事ありがとうございます。残念ながら私は1つだけを選ぶことができます:/ – trickydiddy

関連する問題