html - div-width depends on width of sibling -


following menu trying create.

i want menu item divs independent in width, , have width required text inside thought default behavior. did go wrong?

.patlelast {    padding: 10px;    border-radius: 1000px 0px 1000px 1000px;    background-color: black;    width: auto;    margin: 1px;  }    .patlefirst {    padding: 10px;    border-radius: 1000px 1000px 0px 1000px;    background-color: black;    margin: 1px;  }    .patle {    padding: 10px;    border-radius: 1000px 0px 0px 1000px;    background-color: black;  }    .toppan {    position: fixed;    top: 10px;    right: 0px;    color:white;    font-family: 'raleway', sans-serif;    z-index: 1000;    text-align: right;  }
<div class="toppan">    <div class="patlefirst">      book tickets    </div>    <div class="patle">      screening schedule    </div>    <div class="patlelast">      book tickets    </div>  </div>

this expected behaviour. default display divs block take full width.

to achieve behaviour after make following changes css:

  • add float: right; .patlelast, .patlefirst, .patle - shrink divs fit content
  • add clear: both; .patlelast, .patlefirst, .patle - ensure wrap onto new lines

by floating div width computed "shrink fit".

if 'width' computed 'auto', used value "shrink-to-fit" width.

floating, non-replaced elements (https://www.w3.org/tr/css2/visudet.html#float-width)

.patlelast {    padding: 10px;    border-radius: 1000px 0px 1000px 1000px;    background-color: black;    width: auto;    margin: 1px;  }    .patlefirst {    padding: 10px;    border-radius: 1000px 1000px 0px 1000px;    background-color: black;    margin: 1px;  }    .patle {    padding: 10px;    border-radius: 1000px 0px 0px 1000px;    background-color: black;  }    .patlelast, .patlefirst , .patle {    clear: both;    float: right;  }    .toppan {    position: fixed;    top: 10px;    right: 0px;    color:white;    font-family: 'raleway', sans-serif;    z-index: 1000;    text-align: right;  }
<div class="toppan">    <div class="patlefirst">      book tickets    </div>    <div class="patle">      screening schedule    </div>    <div class="patlelast">      book tickets    </div>  </div>


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -