У ссылки появились лишние пиксели, как избавиться от них?
Поставил header фиксированную высоту в 80px, добавил в него ссылку и в нее обернул картинку(высота 80px), но почему-то ссылка добавила лишние 3 пикселя. Как можно это исправить?
* {
box-sizing: border-box;
}
html {
height: 100%;
width: 100%;
}
.header {
width: 100%;
background-color: #ffffff;
height: 80px;
position: fixed;
border-bottom: 1px solid #D8D8D8;
}
.header__container {
padding: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.header__logo {
height: 80px;
}
.basket {
color: #ffffff;
font-size: 20px;
margin-right: 10px;
}
.header__link {}
#price {
color: #ffffff;
}
.header__group {
width: 250px;
height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
}
.header__group--price {
background-color: #FF7C45;
height: 100%;
padding: 0 15px;
display: flex;
justify-content: center;
align-items: center;
}
.header__button {
padding: 10px;
}
<link rel="stylesheet" href="https://meyerweb.com/eric/tools/css/reset/reset200802.css">
<link href="https://fonts.googleapis.com/css2family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/9c48963e84.js" crossorigin="anonymous"></script>
<header class="header">
<div class="container header__container">
<a href="#" class="header__link">
<img class="header__logo" src="./images/logo.svg" alt="not-found">
</a>
<div class="header__group">
<div class="header__group--price">
<i class="fas fa-shopping-cart basket"></i>
<span id="price">100.00$</span>
</div>
<button class="header__button">Выйти</button>
</div>
</div>
</header>
Ответы (2 шт):
Автор решения: Andrey S
→ Ссылка
*{
box-sizing: border-box;
}
html{
height: 100%;
width: 100%;
}
.header{
width: 100%;
background-color: #ffffff;
height: 80px;
position: fixed;
border-bottom: 1px solid #D8D8D8;
}
.header__container{
padding: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.header__logo{
height: 80px;
}
.basket{
color: #ffffff;
font-size: 20px;
margin-right: 10px;
}
.header__link{
max-height: 80px;
}
#price{
color: #ffffff;
}
.header__group{
width: 250px;
height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
}
.header__group--price{
background-color: #FF7C45;
height: 100%;
padding: 0 15px;
display: flex;
justify-content: center;
align-items: center;
}
.header__button{
padding: 10px;
}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cinema World</title>
<link rel="stylesheet" href="https://meyerweb.com/eric/tools/css/reset/reset200802.css">
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet">
<script src="https://kit.fontawesome.com/9c48963e84.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="src/main.css">
</head>
<body>
<header class="header">
<div class="container header__container">
<a href="#" class="header__link">
<img class="header__logo" src="https://i.imgur.com/0UyDfgp.png" alt="not-found">
</a>
<div class="header__group">
<div class="header__group--price">
<i class="fas fa-shopping-cart basket"></i>
<span id="price">100.00$</span>
</div>
<button class="header__button">Выйти</button>
</div>
</div>
</header>
</body>
вот так? добавить к классу header__link{ max-height: 80px};
Автор решения: Михаил Камахин
→ Ссылка
У меня вроде 80px
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
:root {
--mainColor: orange;
}
body {
min-height: 100%;
}
img {
display: block;
max-width: 100%;
}
header {
--widthHeader: 80px;
max-height: var(--widthHeader);
}
button {
outline: none;
border: none;
}
.container {
max-width: 1000px;
margin: 0 auto;
display: block;
width: 100%;
padding: 0 15px;
}
.flex {
display: flex;
}
.header__link {
display: block;
}
.header__container {
align-items: center;
justify-content: space-between;
}
.header__link img {
max-height: var(--widthHeader);
height: 100%;
}
.header--price {
background-color: var(--mainColor);
align-self: stretch;
display: flex;
align-items: center;
padding: 0 15px;
}
.btn {
--anotherColor: black;
background-color: var(--mainColor);
color: var(--anotherColor);
padding: 10px 15px;
cursor: pointer;
border: 1px solid var(--anotherColor);
border-radius: 5px;
transition-duration: 0.2s;
transition-timing-function: linear;
transition-property: border-color, background-color, color;
}
.btn:hover {
--mainColor: black;
--anotherColor: orange;
}
<script src="https://kit.fontawesome.com/9c48963e84.js" crossorigin="anonymous"></script>
<header>
<div class="container">
<div class="header__container flex">
<a href="#" class="header__link">
<img class="header__logo" src="https://picsum.photos/300/150" alt="not-found">
</a>
<div class="header--price">
<i class="fas fa-shopping-cart basket"></i>
<span id="price">100.00$</span>
</div>
<button class="btn">Выйти</button>
</div>
</div>
</header>
