Как правильно сверстать такой border ? Если бы фон был однотонный (белый, серый..) - то я знаю как решить данную задачу. Но как е] решить, в случае если фон - это какая либо картинка ? Помогите пожалуйста советом.
1 ответ
4 div элемента с абсолютным позиционированием
h1, h2 {
font-family: Nunito;
color: white;
}
body {
background-color: #eee;
width: auto;
}
.image {
background-color: #ededed;
height: 600px;
display: flex;
flex-direction: column;
flex-wrap: 1;
justify-content: center;
align-items: center;
width: auto;
background-image: url("https://images.pexels.com/photos/949587/pexels-photo-949587.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260");
}
h1 span {
position: absolute;
font-size: 1.5rem;
width: 60px;
text-align: center;
top: -15px;
left: 50%;
margin-left: -100px;
}
.button {
position: absolute;
width: auto;
text-align: center;
bottom: -10px;
left: 50%;
font-size: 16px;
margin-left: -30px;
}
.list {
list-style: none;
text-align: left;
padding-left: 50%;
}
.title-box {
height: 200px;
width: 400px;
text-align: center;
position: relative;
padding-top: 10px;
margin-left: auto;
margin-right: auto;
margin-bottom: 51px;
opacity: 0.9;
color: #ffffff;
}
.title-border {
position: absolute;
top: 0;
bottom: 0;
width: 71px;
border-top: 1px solid;
border-bottom: none;
border-left: 1px solid;
border-right: 1px solid;
}
.title-border-top-left {
border-right: none;
}
.title-border-top-right {
left: auto;
right: 0;
border-left: none;
}
.title-border-bottom-left {
width: 100px;
border-right: none;
border-top: none;
border-bottom: 1px solid;
}
.title-border-bottom-right {
width: 100px;
left: auto;
right: 0;
border-left: none;
border-top: none;
border-bottom: 1px solid;
}
<html>
<head>
<link rel="stylesheet" href="./style.css">
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="image">
<h1>Международная онлайн школа</h1>
<div class="title-box">
<h1><span>Програмирования</span></h1>
<ul class="list">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<button class="button">Registration</button>
<div class="title-border title-border-top-left"></div>
<div class="title-border title-border-bottom-left"></div>
<div class="title-border title-border-top-right"></div>
<div class="title-border title-border-bottom-right"></div>
</div>
</body>
</html>
-
это в случае с однотипным фоном. так я тоже могу. мне нужно именно что бы на фоне картинки. дабы этому тексту я не мог задать бэкграунд ( – Роман Тимощук 29 июл '20 в 22:18
-
-
-
-
СПАСИБО! Поиграюсь с адаптивом, надеюсь получится) а то уже второй день не могу понять как это лучше сделать. – Роман Тимощук 29 июл '20 в 22:51