Как центрировать блок по центру?

188
22 января 2019, 18:20

Как разместить блок div с классом "tabs" по центру?

   .tabs { 
display: flex; 
min-width: 980px; 
min-height: 93px; 
border-bottom: 4px solid #E7E7E7; 
/*background-color: black;*/ 
margin-top: 156px; 
} 
 
.tabOne { 
min-height: 43px; 
min-width: 170px; 
} 
 
.tabTwo { 
min-width: 258px; 
min-height: 43px; 
} 
 
.tabTree { 
min-width: 268px; 
min-height: 43px; 
} 
 
.circle { 
width: 43px; 
height: 43px; 
background: #5F5F5F; 
-moz-border-radius: 50px; 
-webkit-border-radius: 50px; 
border-radius: 50px; 
} 
 
.circle2 { 
width: 43px; 
height: 43px; 
background: #5F5F5F; 
-moz-border-radius: 50px; 
-webkit-border-radius: 50px; 
border-radius: 50px; 
} 
 
.circle3 { 
width: 43px; 
height: 43px; 
background: #5F5F5F; 
-moz-border-radius: 50px; 
-webkit-border-radius: 50px; 
border-radius: 50px; 
} 
 
.circle:hover { 
background-color: #ADD136; 
} 
 
.circle2:hover { 
background-color: #ADD136; 
} 
 
.circle3:hover { 
background-color: #ADD136; 
} 
 
.one { 
color: white; 
text-align: center; 
font-size: 20px; 
padding-top: 10px; 
} 
 
.two { 
color: white; 
text-align: center; 
font-size: 20px; 
padding-top: 10px; 
} 
 
.tree { 
color: white; 
text-align: center; 
font-size: 20px; 
padding-top: 10px; 
}
 <div class="tabs" > 
        <!-- tabOne --> 
            <div class="tabOne" > 
                <div class="circle" > 
                    <p class="one" >1</p> 
                </div> 
            </div> 
        <!-- /tabOne --> 
 
        <!-- tabTwo --> 
            <div class="tabTwo" > 
                <div class="circle2" > 
                    <p class="two" >2</p> 
                </div> 
            </div> 
        <!-- /tabTwo --> 
 
        <!-- tabTree --> 
            <div class="tabTree" > 
                <div class="circle3" > 
                    <p class="tree" >3</p> 
                </div> 
            </div> 
        <!-- /tabTree --> 
 
        </div>

Заранее спасибо за помощь.

Answer 1
  1. у табс выставлена минимальная ширина, значит на десктопах данный блок будет по ширине 100%.
  2. устанавливаем ширину, делаем через width или max-width
  3. после устанавливаем параметр margin:0 auto, что позволяет разместить блок по центру.

     .tabs { 
        display: flex; 
        max-width: 980px; 
        min-height: 93px; 
        border-bottom: 4px solid #E7E7E7; 
        margin: 0 auto; 
        }

READ ALSO
Ошибка Angular в mean.io при сборке

Ошибка Angular в mean.io при сборке

Скачал последнюю версию meanio с помощью Git,

173
Boostrap 4 accordion несколько штук

Boostrap 4 accordion несколько штук

у меня есть таблица в виде аккордиона

168
Как сделать из div-a ссылку?

Как сделать из div-a ссылку?

Мне нужно, чтобы при клике на div(там на сайте целый блок), осуществлялся бы переход на другую страницуКак это можно реализовать с помощью JQuery?

150
WPF привязка DataContext к полю родительского DataContext

WPF привязка DataContext к полю родительского DataContext

Есть у меня главная форма, у нее в DataContext указана модель этой формыВ этой модели есть свойство, ссылающееся на другую модель

151