Ich haben ein Bild und etwas Text in p-Tag und Link vertikal ausgerichtet werden. Es funktioniert gut, wenn ich das Bild schwebe. Aber wenn ich Padding im p-Tag und im Link verwende, wird das Padding nicht perfekt.
click here to see the image I need look like
here is a fiddleBild und mehrere Textzeilen und Links vertikaler Ausrichtung
.wrapper {
font-family: sans-serif;
width: 400px;
margin-top: 30px;
margin-bottom: 30px;
clear:both
}
img {
float: left;
}
p.text {
padding-left: 30px;
display: block;
padding-bottom: 22px;
color: #222222;
}
a.link {
text-decoration: none;
padding-left: 30px;
text-transform: uppercase;
line-height: 22px;
color: #777777;
}
a.date {
color: #e10622;
text-decoration: none;
}
<div class="wrapper">
<img src="https://placehold.it/100x100" alt="">
<p class="text">Posted By: Simon | <a href="#" class="date"> 26 July 2016</a></p>
<a href="#" class="link">Days are all happiness is key
and Free</a>
</div>
<div class="wrapper">
<img src="https://placehold.it/100x100" alt="">
<p class="text">Posted By: Simon | <a href="#" class="date"> 26 July 2016</a></p>
<a href="#" class="link">Days are all happiness is key
and Free</a>
</div>
<div class="wrapper">
<img src="https://placehold.it/100x100" alt="">
<p class="text">Posted By: Simon | <a href="#" class="date"> 26 July 2016</a></p>
<a href="#" class="link">Days are all happiness is key
and Free</a>
</div>
<br>
<br>
<br>
<a href="http://prntscr.com/cpusej" style="text-align:center; display: block; padding: 10px; background: #f44; font-size: 18px">Please see here what I need</a>
Dank im Voraus. :)
Es löste mein Problem :). Aber ich würde gerne wissen, warum ich die Marge im IMG bereitstellen muss. Was ist das Problem mit dem Text? –
Zwei Gründe. Zuerst müssen Sie es nur an einer Stelle statt an zwei Stellen einstellen/aktualisieren. Zweitens, wegen des Floatens auf dem Bild ignoriert jegliches Padding oder Rand auf den Elementen daneben (d. H. Die "p.text" - und "a.link" -Elemente) das Bild vollständig. Da Ihr Bild 100 px breit ist, werden Ihre Elemente in das Bild eingefügt, bevor Sie die Padding-/Randbegrenzungen erreichen. Du könntest deinen "margin-left" oder "padding-left" auf "130px" setzen und es würde technisch funktionieren, aber es schien mir sauberer zu sein, es einfach auf das Bild zu setzen. – manwill
Vielen Dank. Und tut mir leid, dass ich dich belästigt habe. Da ich ein neuer Lerner bin, wird es mir sicher helfen. Guten Tag :) –