【发布时间】:2017-01-19 21:04:36
【问题描述】:
有没有办法让跨度和段落之间有一条水平线。该行应与段落具有相同的宽度。 我怎样才能完成这个? 我不能使用 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;
}
这里试图解决 position: absolute 的问题。问题是每个标题都以不同的高度开始,因为 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>
【问题讨论】:
-
显然这应该是一个带有标题和段落的 div,而不是段落和跨度。您可能需要考虑重新格式化您的结构。