Reputation: 539
I have the following code :
<div class='relative'>
<span>MyText</span><br>
<span class="btnFavorit btnViolet" idp="005626">
<span class="l"> </span><span class="c"> <img class="imageOff" src="./charte/base/mesCourses/pictoFavorit.png"><img class="imageOn" src="./charte/base/mesCourses/pictoFavoritOn.png">BUTTON</span><span class="r"> </span>
</span>
</span>
</div>
I would like to put a margin bottom on the first span to have a space between the text and my button (made by span) . How I can do it (For me I think I will use other
but I don't know if I can use CSS for this)
Upvotes: 1
Views: 1208
Reputation: 1624
You can have more space between these spans. You can set css rule to do it:
br {
line-height:10px;
}
or
br {
margin: 15px 0;
display: block;
}
That would change all brs in your page. Add class to br in order to have css specific in only one place:
<span>MyText</span><br class="gap">
and then you use css:
br.gap {
margin: 15px 0;
display: block;
}
Upvotes: 1
Reputation: 1064
Use some thing like this..
<style>
.relative span:first-of-type { display:inline-block;margin-bottom:10px; }
</style>
Upvotes: 0
Reputation: 1345
The span tag should be used for inline elements ONLY. Best solution would be to change MyText span to a div, as this is your desired effect.
<div>MyText</div>
Upvotes: 0
Reputation: 5774
Just add class to first span, give it a display property as inline-block
or block
and put margin :-)
.textSpan{
display:inline-block;
margin-bottom:5px; /*increase if you want*/
}
Why only margin does not work for span
?
Span element is inline
unlike block elements like p, div
hence you need to specifically give it a custom display property like block
or inline-block
Upvotes: 0
Reputation: 525
This should work
.relative span { display: inline-block; }
.relative span:first-child { margin-bottom: 10px; }
Upvotes: 5