Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS border-radius

Tags:

css

<style>
  div {border-radius:5px;background:#cccccc;}
  span {display:block;}
</style>

<div>
    <span>First line</span>
    <span>Second line</span>
</div>

I want each span to fit inside the div with rounded corners, but they go in front of the div and obscure the rounded corners. If I put rounded corners on each span then you can see a faint outline of each span, even if they have the same background-color as the div.

like image 395
user774528 Avatar asked Oct 17 '25 05:10

user774528


2 Answers

try overflow:hidden on the div? or give it a z-index of 1000

like image 185
Ben Avatar answered Oct 21 '25 14:10

Ben


alternative to @AlexC's answer:

<style>
  div {border-radius:5px;background:#cccccc;}
  span {padding:0px 5px;display:block;}
  .topspan {padding:5px 5px 0px 5px;display:block;}
  .bottomspan {padding:0px 5px 5px 5px;display:block;}
</style>

<div>
    <span class="topspan"></span>
    <span>First line</span>
    <span>Second line</span>
    <span class="bottomspan"></span>
</div>

see here

like image 22
besamelsosu Avatar answered Oct 21 '25 15:10

besamelsosu