Как я могу установить Высота навигации <div>такая же, как высота круга <div>без жесткого кодирования любого значения - PullRequest
0 голосов
/ 28 февраля 2019

У меня есть скрипка,

https://jsfiddle.net/thakv1/9zf1tm7q/2/

HTML: -

<div class = "single-page">
  <div class="navigation">
    <div class ="circle">
      1
    </div>
  </div>
  <div class="content">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
</div>

CSS: -

.single-page{
  display: flex;
  flex-flow: row nowrap;
}
.content{
  height: 400px;
  flex:1;
  background-color:white;
}
.navigation{
  width : 52px;
}
.circle{
    width: 30px;
    line-height: 30px;
    border-radius: 50%;
    text-align: center;
    background-color: #295ED9;
    color: white;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    margin: 20px 10px;
}

В этой скрипкевысота навигации составляет 400 пикселей, я хочу, чтобы высота навигации была равна высоте круга div (около 30 пикселей), а не содержанию div. Как мы можем этого добиться.

1 Ответ

0 голосов
/ 28 февраля 2019

Вы должны добавить align-self:flex-start к .navigation

.single-page{
  display: flex;
  flex-flow: row nowrap;
}
.content{
  height: 400px;
  flex:1;
  background-color:red;
}
.navigation{
  width : 52px;
  background: red;
  align-self:flex-start;
}
.circle{
    width: 30px;
    line-height: 30px;
    border-radius: 50%;
    text-align: center;
    background-color: #295ED9;
    color: white;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    margin: 20px 10px;
}
<div class = "single-page">
  <div class="navigation">
    <div class ="circle">
      1
    </div>
  </div>
  <div class="content">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...