Javascript-форум (https://javascript.ru/forum/)
-   (X)HTML/CSS (https://javascript.ru/forum/xhtml-html-css/)
-   -   Выравнивание блоков (https://javascript.ru/forum/xhtml-html-css/54608-vyravnivanie-blokov.html)

Sanu0074 24.03.2015 17:03

Выравнивание блоков
 
Есть такая структура

<div class="top">
        <div class="label">
            Приветсвуем тебя на сайте <span>super site</span>
            <div class="search-button"><span></span></div>
        </div>
        <div class="user-bl">
            Вход на сайт
        </div>
    </div>

.top{
    background: $topBg;
    height: 50px;
    position:relative;
    border-top: 2px solid $mainGreen;
    border-bottom:1px solid $cSilver15;
    & .label{
        position:relative;
        display: inline-block;
        vertical-align: middle;
        padding:0 50px 0 100px;
        line-height: 50px;
        color: $cSilver10;
        font-size: 20px;
        background:red;
        & span{
            font-family: Calibri;
            font-size: 24px;
            color: $topLabel;
            text-transform: uppercase;
        }
        & .search-button{
            position: absolute;
            width: 70px;
            top:0;
            right: -70px;
            bottom: 0;
            & span{
                position: absolute;
                top:0;bottom: 0;left:0;right:0;
                background:url(../img/sprite.png) no-repeat 18px 9px
            }
        }
    
    }
    
    & .user-bl{
        float: right;
        line-height: 50px;
        color: #fff;
        cursor: pointer;
        padding: 0 15px;
    }
}

Нужно блок приветствия заставить пристыковаться в упор к блоку входа на сайт, при этом не использовать фиксированную ширину или javascript. Как это сделать?

hfts_rider 24.03.2015 17:27

<!DOCTYPE HTML>
<html>
  <head> </head>
  <body>
	<style>
      *{margin:0;padding:0}
      .top{height:50px;position:relative;}
      .label{float:left;height:100%;width: calc(100% - 100px);background-color:#f00}
      .user-bl{float:right;width:100px;height:100%;background-color:#acacac}
	</style>

<div class="top">
        <div class="label">
            Приветсвуем тебя на сайте <span>super site</span>
            <div class="search-button"><span></span></div>
        </div>
        <div class="user-bl">
            Вход на сайт
        </div>
</div>

  </body>
</html>

hfts_rider 24.03.2015 17:29

Только левый блок должен быть с float:left

Sanu0074 24.03.2015 18:01

спасибо)


Часовой пояс GMT +3, время: 23:38.