@vovkka

Что читать чтобы понять вложенность css?

Доброго вечера всем!
Подскажите пожалуйста что читать либо какие видео посмотреть чтобы разобраться во вложенности css.
Сколько пишу css не могу понять как правильно делать, к примеру:

<header class="header">
				<div class="header-holder clearfix">
					<form action="" method="" class="search-form">
						<input type="text" name="search_query" placeholder="Введите вопрос" class="search-main-input">
						<input type="submit" name="" class="search-main-submit">
						<div class="close"></div>
					</form>
					<div class="header-contacts">
						<a href="#form-popup" class="message"></a>
						<a href="#" class="search"></a>
						<div class="header-contacts-tel">(343) 287 85 85</div>
					</div>
					<div class="header-logo">
						<a href="#">
							<img src="img/logo.png" alt="БТИКР">
						</a>
					</div>
					<nav>
						<div class="mobile-menu">
							<a href="#">Меню</a>
						</div>
						<ul>
							<li><a href="#">О нас</a></li>
							<li><a href="#">Услуги</a></li>
							<li><a href="#">Проекты</a></li>
							<li><a href="#">Документы</a></li>
							<li><a href="#">Контакты</a></li>
						</ul>
					</nav>
				</div>
			</header>


css получается таким (scss):
.header {
	min-height: 190px;
	width: 100%;
	padding: 80px 0 60px 0;
	font-family: 'PFBeauSansPro-Regular';
	.header-holder {
		position: relative;
		width: 100%;
		max-width: 1681px;
		margin: 0 auto;
		padding: 0 25px;
		.header-logo {
			float: left;
			max-width: 267px;
			a {
				display: inline-block;
			}
		}
		nav {
		    // margin-right: 20%;
		    float: right;
		    line-height: 48px;
		    .mobile-menu {
		    	position: relative;
		    	display: none;
		    	width: 100%;
		    	font-size: em(22);
		    	text-align: center;
		    	&:before {
		    		content: '';
		    		position: absolute;
		    		width: 100%;
		    		height: 1px;
		    		background: #777;
		    		top: 5px;
		    		left: 0;
		    	}
		    	a {
		    		position: relative;
		    		width: 100%;
		    		height: 30px;
		    		display: inline-block;
		    		text-decoration: none;
		    		color: #000;
		    		&:after {
		    			content: '';
		    			width: 16px;
		    			height: 11px;
		    			position: absolute;
		    			top: 60%;
		    			margin-left: 13px;
		    			background: url('../img/icon_menu_ug.png') no-repeat;
		    		}
		    	}
		    	a.show {
		    		&:after {
		    			content: '';
		    			width: 16px;
		    			height: 11px;
		    			position: absolute;
		    			top: 60%;
		    			margin-left: 13px;
		    			background: url('../img/icon_menu_ug.png') no-repeat;
		    			transform: rotate(180deg);
		    		}
		    	}
		    }
		  }
		  nav ul li {
		  	display: inline-block;
		  	a {
		  		position: relative;
		  		color: #000;
		  		text-decoration: none;
		  		font-size: em(22);
		  		padding: 0 25.5px;
		  		text-transform: uppercase;
		  		background: transparent;
		  		padding-bottom: 0px;
		  		&::after {
		  			content: '';
		  			position: absolute;
		  			width: 100%;
		  			height: 2px;
						bottom: -3px;
						left: 10%;
						background: url('../img/poloska.png') repeat-x bottom;
		  			padding-bottom: 5px;
		  			opacity: 0;
		  			transition: all .5s;
		  		}
		  		&:hover::after {
		  			// text-decoration: underline;
		  			opacity: 1;
		  			left: 0;
		  		}
		  	}
		  }
		  .header-contacts {
		  	position: relative;
		  	float: right;
		  	// display: flex;
		  	// justify-content: flex-start;
		  	// flex-direction: row;
		  	display: block;
		  	margin-top: 13px;
		  	.message {
		  		float: left;
		  		display: inline-block;
		  		width: 28px;
		  		height: 25px;
		  		padding-right: 40px;
		  		margin-right: 10px;
		  		border-right: 2px solid #000;	
		  		background: url('../img/obratnaya-svyaz.png') no-repeat;
		  		&:hover {
		  			cursor: pointer;
		  			background: url('../img/obratnaya-svyaz_h.png') no-repeat;
		  		}
		  	}
		  	.search {
		  		float: left;
		  		display: inline-block;
		  		width: 28px;
		  		height: 25px;
		  		padding-right: 40px;
		  		margin-right: 10px;
		  		border-right: 2px solid #000;	
		  		background: url('../img/search.png') no-repeat;
		  		&:hover {
		  			cursor: pointer;
		  			background: url('../img/search_h.png') no-repeat;
		  		}
		  	}
		  	.header-contacts-tel {
		  		float: left;
		  		font-size: em(21);
		  		// display: flex;
		  		// align-items: center;
		  	}
		  }
		}
	}


Видите какая вложенность, это ведь не правильно как по моему.
Плюс подскажите по поводу БЭМ или чего либо другого.... что лучше изучить ?
Всем добра!
  • Вопрос задан
  • 189 просмотров
Пригласить эксперта
Ответы на вопрос 3
iiiBird
@iiiBird Куратор тега CSS
Пока ты спишь - твой конкурент совершенствуется
ну вот ты сам ответил на свой вопрос. изучай БЭМ. тогда и не будет такой вложенности
Ответ написан
Комментировать
Ankhena
@Ankhena Куратор тега CSS
Нежно люблю верстку
https://ru.bem.info/

А по вашему коду: .header-holder, header-logo и т.д. кроме блока header не встречаются. Зачем творите такие гармошки: .header .header-holder .header-logo?

Тогда уж:
.header {
    стили
    &-holder {
        стили
    }
}
Ответ написан
sfi0zy
@sfi0zy Куратор тега CSS
Creative frontend developer
подскажите по поводу БЭМ или чего либо другого.... что лучше изучить ?

Ну про БЭМ вы уже знаете. Есть аналог c менее монструозными классами - rscss.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы