Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inner span overflows past outer span

Tags:

html

css

I need your help,

I can't seem to figure out as to why my inner span overflows past my outer span?

Here is a pic of the problem:

enter image description here

Here is the HTML and CSS markup:

<span style="border: 1px solid blue; display:inline-block; position: relative; width: 100%;">
     <span style="display:inline-block; border:1px solid red; text-align: right; width:100%">
       test
     </span>
</span>
like image 635
BobbyJones Avatar asked Jul 10 '26 05:07

BobbyJones


1 Answers

span{
    box-sizing: border-box;
}
<span style="border: 1px solid blue; display:inline-block; position: relative; width: 100%;">
     <span style="display:inline-block; border:1px solid red; text-align: right; width:100%">test</span>
</span>

apply this css rule:

span{
    box-sizing: border-box;
}

border-box : The width and height properties (and min/max properties) includes content, padding and border, but not the margin

You can find more about box-sizing here

like image 86
Kristijan Iliev Avatar answered Jul 11 '26 19:07

Kristijan Iliev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!