html - CSS Set width of an element -
i trying set width of element progress
width between 2 other elements. here html code using
<span class="current_rank"><?php echo $this->current_rank;?></span> <div class="progress"> <div class="progress-bar" role="progressbar"></div> </div> <span class="next_rank"><?php echo $this->next_rank;?></span>
i trying width of progress bar width between 2 <span>'s
possible css?
update
.progress { width: 550px; height: 15px; margin-bottom: 10px; overflow: hidden; background-color: #666; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); } .progress-bar { width: 0; height: 100%; font-size: 12px; line-height: 15px; color: #333; text-align: center; background-color: #ffd700; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); -webkit-transition: width 0.6s ease; transition: width 0.6s ease; } .vip_ranking > .current_rank { margin-left: 30px; margin-right: 25px; } .vip_ranking > .next_rank { float: right; margin-right: 22.5px; } .vip_ranking > div.progress{ position:absolute; display:inline; margin-left: 10px; }
there several css solutions, depends requirements, in terms of browsers compatibility.
css calc function - can use if know width of span elements, either absolute width or width in percentage. example: width: calc(100% - 200px) or calc(80%). solution work in ie9+, chrome , ff
using display:flex; , justifying content. can read more here. not need know width of spans, solution compatible in ie10+, chrome , ff.
Comments
Post a Comment