I have created the following list within a div that is centered by flex.
As you can see in the snippet, the list is not centered (as I would expect with using flex on the list-div2 and the translate rule in the parents middle-text div.
Can someone help me? Why does it not get centered properly?
body {
margin: 0;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
height: 100vh;
background-color: white;
}
.container>div {
min-height: 100vh;
border: 1px solid black;
box-sizing: border-box;
background-color: inherit;
}
.container>div .content {
height: 100vh;
width: 100vw;
background-color: inherit;
}
.full-width {
width: 100%;
}
.half-width {
width: 50%;
}
.full-width>.content>.third-parent {
height: 100%;
display: flex;
flex-direction: row;
}
.full-width>.content>.third-parent>.third {
position: relative;
flex: 1 1 0px;
border: 1px solid black;
width: 100%;
}
.full-width>.content>.third-parent>.third>img {
position: absolute;
width: 100%;
height: auto;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.middle-text {
position: absolute;
width: 100%;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 li {
position: relative;
display: block;
border: 1px solid red;
margin-bottom: 5px;
padding: 10px;
text-align: center;
text-transform: uppercase;
visibility: visible;
list-style-type: bullet;
}
<div class="container">
<div class="full-width">
<div class="content">
<div class="third-parent">
<div class="third" id="one">
<img src="https://fakeimg.pl/350x200/?text=left">
</div>
<div class="third" id="two">
<div class="middle-text">
<h1>Headline</h1>
<div class="list-div2">
<ul class="items-list2" id="list">
<li>Entry A</li>
<li>Entry B</li>
<li>Entry C</li>
<li>Entry D</li>
</ul>
</div>
</div>
</div>
<div class="third" id="three">
<img src="https://fakeimg.pl/350x200/?text=right">
</div>
</div>
</div>
</div>
</div>
That's because of the padding/margin that browsers add to the ul tag by default.
Example:
body {
margin: 0;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
height: 100vh;
background-color: white;
}
.container>div {
min-height: 100vh;
border: 1px solid black;
box-sizing: border-box;
background-color: inherit;
}
.container>div .content {
height: 100vh;
width: 100vw;
background-color: inherit;
}
.full-width {
width: 100%;
}
.half-width {
width: 50%;
}
.full-width>.content>.third-parent {
height: 100%;
display: flex;
flex-direction: row;
}
.full-width>.content>.third-parent>.third {
position: relative;
flex: 1 1 0px;
border: 1px solid black;
width: 100%;
}
.full-width>.content>.third-parent>.third>img {
position: absolute;
width: 100%;
height: auto;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.middle-text {
position: absolute;
width: 100%;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 li {
position: relative;
display: block;
border: 1px solid red;
margin-bottom: 5px;
padding: 10px;
text-align: center;
text-transform: uppercase;
visibility: visible;
list-style-type: bullet;
}
.items-list2 {
margin: 0;
padding: 0;
}
<div class="container">
<div class="full-width">
<div class="content">
<div class="third-parent">
<div class="third" id="one">
<img src="https://fakeimg.pl/350x200/?text=left">
</div>
<div class="third" id="two">
<div class="middle-text">
<h1>Headline</h1>
<div class="list-div2">
<ul class="items-list2" id="list">
<li>Entry A</li>
<li>Entry B</li>
<li>Entry C</li>
<li>Entry D</li>
</ul>
</div>
</div>
</div>
<div class="third" id="three">
<img src="https://fakeimg.pl/350x200/?text=right">
</div>
</div>
</div>
</div>
</div>
Actually user agent stylesheet have padding left. So you need to overwrite that style by ul{padding-left: 0}
ul, menu, dir {
display: block;
list-style-type: disc;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;
}
You should give padding: 0; to your ul
ul.items-list2 {
padding: 0;
}
The W3C spec says ul has as default margin of 40px, but different browsers over ride this. So its always good to normalize margins and paddings.
body {
margin: 0;
}
ul.items-list2 {
padding: 0;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
height: 100vh;
background-color: white;
}
.container>div {
min-height: 100vh;
border: 1px solid black;
box-sizing: border-box;
background-color: inherit;
}
.container>div .content {
height: 100vh;
width: 100vw;
background-color: inherit;
}
.full-width {
width: 100%;
}
.half-width {
width: 50%;
}
.full-width>.content>.third-parent {
height: 100%;
display: flex;
flex-direction: row;
}
.full-width>.content>.third-parent>.third {
position: relative;
flex: 1 1 0px;
border: 1px solid black;
width: 100%;
}
.full-width>.content>.third-parent>.third>img {
position: absolute;
width: 100%;
height: auto;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.middle-text {
position: absolute;
width: 100%;
left: 50%;
top: 50%;
visibility: visible;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.full-width>.content>.third-parent>.third>.middle-text>.list-div2 li {
position: relative;
display: block;
border: 1px solid red;
margin-bottom: 5px;
padding: 10px;
text-align: center;
text-transform: uppercase;
visibility: visible;
list-style-type: bullet;
}
<div class="container">
<div class="full-width">
<div class="content">
<div class="third-parent">
<div class="third" id="one">
<img src="https://fakeimg.pl/350x200/?text=left">
</div>
<div class="third" id="two">
<div class="middle-text">
<h1>Headline</h1>
<div class="list-div2">
<ul class="items-list2" id="list">
<li>Entry A</li>
<li>Entry B</li>
<li>Entry C</li>
<li>Entry D</li>
</ul>
</div>
</div>
</div>
<div class="third" id="three">
<img src="https://fakeimg.pl/350x200/?text=right">
</div>
</div>
</div>
</div>
</div>
Related
The purple Navbar at the top of the page pushes the container "container2" off screen. Is there any possible way I can make it so the "container2" div does not overflow with the proper padding of 5px at the bottom?
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/ * { box-sizing: border-box; margin: 0; }
html {
height: 100%;
width: 100%
}
body {
background: black;
height: 100%;
position: relative;
overflow: hidden;
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 100%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one { width: 10%; background: red; }
.two { width: 90%; background: blue; }
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
Resulting Page
I am new to HTML and CSS so any helps greatly appreciated.
Stack overflow wants more content besides code but im not too sure what else to add.
Remove overflow: hidden from body:
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/
* {
box-sizing: border-box;
margin: 0;
}
html {
height: 100%;
width: 100%
}
body {
background: black;
height: 100%;
position: relative;
/*overflow: hidden;*/
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 100%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one {
width: 10%;
background: red;
}
.two {
width: 90%;
background: blue;
}
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/ * { box-sizing: border-box; margin: 0; }
body {
background: black;
height: 100vh;
position: relative;
overflow: hidden;
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
height: 20%;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 80%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one { width: 10%; background: red; }
.two { width: 90%; background: blue; }
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
you should divide the height of navbar and container 2
#draggable-container {
margin: 0 auto;
display: flex;
flex-wrap: nowrap;
align-items: center;
}
.draggable-game-content {
width: 100%;
height: 40rem;
}
.draggable-game {
position: relative;
border: 1px solid black;
border-radius: 25px;
margin-left: 1.5rem;
height: 38rem;
text-align: center;
}
#menu-container {
width: 4rem;
height: 30rem;
border: 1px solid #000;
border-radius: 15px;
position: relative;
}
.menu-list {
position: absolute;
left: 25%;
top: 50%;
transform: translate(-50%, -50%);
}
.menu-item {
display: block;
margin-bottom: 1.5rem;
border-radius: 50%;
border: 1px solid #000;
height: 2.5rem;
width: 2.5rem;
}
.menu-item:nth-child(2) {
margin-bottom: 7rem;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div id="draggable-container">
<div id="menu-container">
<ul class="menu-list">
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item">info</li>
<li class="menu-item">settings</li>
<li class="menu-item">achievements</li>
</ul>
</div>
<div class="draggable-game-content">
<div class="draggable-game">test</div>
</div>
</div>
</div>
I have this page generated by React and I don't understand why the div with "test" stays up while the left menu goes down.
I want to make them stay at the same level, like this:
I thought I will achieve this by setting align-items to center (so they will center vertically) and start at the same point, but actually it doesn't work.
Why is my approach not valid and how can I achieve the layout from the page?
Your's align-items should be flex-start
#draggable-container {
margin: 0 auto;
display: flex;
flex-wrap: nowrap;
align-items: flex-start;
}
#draggable-container {
margin: 0 auto;
display: flex;
flex-wrap: nowrap;
align-items: flex-start; // updated this line only
}
.draggable-game-content {
width: 100%;
height: 40rem;
}
.draggable-game {
position: relative;
border: 1px solid black;
border-radius: 25px;
margin-left: 1.5rem;
height: 38rem;
text-align: center;
}
#menu-container {
width: 4rem;
height: 30rem;
border: 1px solid #000;
border-radius: 15px;
position: relative;
}
.menu-list {
position: absolute;
left: 25%;
top: 50%;
transform: translate(-50%, -50%);
}
.menu-item {
display: block;
margin-bottom: 1.5rem;
border-radius: 50%;
border: 1px solid #000;
height: 2.5rem;
width: 2.5rem;
}
.menu-item:nth-child(2) {
margin-bottom: 7rem;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div id="draggable-container">
<div id="menu-container">
<ul class="menu-list">
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item">info</li>
<li class="menu-item">settings</li>
<li class="menu-item">achievements</li>
</ul>
</div>
<div class="draggable-game-content">
<div class="draggable-game">test</div>
</div>
</div>
</div>
In Flex to align your items, you must use the align-items property.
You can read more about Flex and its properties in this article.
#draggable-container {
margin: 0 auto;
display: flex;
flex-wrap: nowrap;
align-items: flex-start;
}
This page is a grid container with some images as posts-list, header, and left menu:
JSFiddle1
When I hover over images two links: "comments" and "view posts" would appear. I want to use the CSS and when I click on either of these two it leads me to something like this:
JSFiddle
I wanted to use display: none; but I don't know where should I put it.
if I understand your question correctly, this is a possible solution to your problem.
function changeContainer(){
if($('.grid-container-before').css('visibility') === 'visible') {
$('.grid-container-before').css('visibility','hidden');
$('.grid-container-before').css('display','none');
$('.grid-container-after').css('visibility','visible');
$('.grid-container-after').css('display','grid');
}
}
body {
padding-top: 73px;
overflow-y: hidden;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
/* ------------ PAGE SCROLLBAR ------------ */
*::-webkit-scrollbar {
width: 2px;
}
*::-webkit-scrollbar-track {
background: white;
}
*::-webkit-scrollbar-thumb {
background-color: grey;
border-radius: 20px;
height: 2px;
}
/* ------------ navbar ------------ */
.header {
display: flex;
position: fixed;
background-color: white;
width: 100%;
justify-content: space-between;
z-index: 7;
font-family: Libre Franklin;
top: 0;
left: 0;
}
.header-flex-list {
display: flex;
margin-top: 10px;
justify-content: flex-end;
flex: 50%;
}
.header-list {
list-style: none;
display: flex;
}
.header-list a {
text-decoration: none;
color: #000;
font-size: 12px;
padding: 0px 20px 0px 20px;
}
.top-icon-container {
display: flex;
padding: 10px 50px;
flex-wrap: wrap;
}
.icon-column {
width: 10%;
border-radius: 50px;
}
.p-column {
width: 28%;
padding-left: 10px;
}
#top-bar-icon {
display: block;
max-width: 100%;
height: auto;
object-fit: cover;
border-radius: 50px;
border: 2px solid #73AD21;
}
/* ------------ LEFT MENU ------------ */
.container {
display: flex;
justify-content: space-between;
height: 100vh;
}
.left-menu {
width: 18%;
order: 1;
height: 100vh;
/* overflow-y: scroll; */
padding: 0px 0px 10px 45px;
}
.menu-list {
list-style: none;
line-height: 2.5rem;
/* display: flex;
flex-direction: column; */
margin-left: -25px;
}
.menu-list a {
text-decoration: none;
}
/* ------------ MAIN POSTS ------------ */
.main-posts {
width: 100%;
order: 2;
padding: 0px 20px 0px 20px;
overflow-y: auto;
text-align: center;
scrollbar-width: thin;
scrollbar-color: grey white;
}
/* ------------ MAIN POSTS LISTS ------------ */
.grid-container-before {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
grid-gap: 1rem;
width: 100%;
margin: 0 auto;
margin-bottom: 6rem;
visibility: visible;
}
.grid-container-after {
display: grid;
grid-template-columns: 80% 1fr;
grid-gap: 10px;
height: 300px;
visibility: hidden;
display:none;
}
.box {
background-color: #20262e;
color: #fff;
border-radius: 3px;
padding: 20px;
font-size: 14px;
}
.posts {
display: flex;
}
.img__wrap {
position: relative;
}
.posts-image {
height: 350px;
width: 100%;
object-fit: cover;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: white;
color: #000;
visibility: hidden;
opacity: 0;
/* transition effect. not necessary */
transition: opacity 0.2s, visibility 0.2s;
}
.text {
color: white;
font-size: 15px;
position: absolute;
top: 50%;
left: 50%;
width: 100%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
.text a {
color: #000;
text-decoration: none;
padding-right: 20px;
}
[data-title]::after {
content: attr(data-title);
background-color: #000;
color: #fff;
font-size: 13px;
;
position: absolute;
padding: 10px;
bottom: -3.6em;
left: 50%;
white-space: nowrap;
box-shadow: 1px 1px 3px #222222;
opacity: 0;
border: 1px solid #111111;
z-index: 99999;
visibility: hidden;
}
[data-title]:hover::after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
[data-title] {
position: relative;
}
.img__wrap:hover .overlay {
visibility: visible;
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<head>
<link href="//fonts.googleapis.com/css?family=Karla|Syne|Libre+Franklin|Bai+Jamjuree|Chakra+Petch|Gotu" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<!------------ TOP MENU ------------>
<header id="header" class="header">
<div id="top-container" class="top-icon-container">
<div class="icon-column">
<img id="top-bar-icon" src="https://s4.uupload.ir/files/top-bar-icon_ensh.png" alt="my logo:)">
</div>
<div class="p-column">
<p>Name it what u want!</p>
</div>
</div>
<div class="header-flex-list">
<ul class="header-list">
<li>TERMS OF USE</li>
<li>HAVE A QUESTION</li>
<li>ABOUT ME</li>
</ul>
</div>
</header>
<body>
<div class="container">
<!------------ LEFT MENU ------------>
<nav id="menu" class="left-menu">
<p style="text-decoration: none; color: black;">Filter by:</p>
<ul class="menu-list">
<li><a>Popular pages</a></li>
<li><a>About pages</a></li>
<li><a>Character pages</a></li>
<li><a>Music pages</a></li>
</ul>
</nav>
<!------------ MAIN POSTS ------------>
<section id="main-content" class="main-posts">
<div class="grid-container-before">
<div class="img__wrap">
<img class="posts-image" src="https://www.webdevelopersnotes.com/wp-content/uploads/random-image-display-using-javascript-2.png" alt="project" />
<div class="overlay">
<div class="text">
<button href="#" data-title="comments" onclick="changeContainer()">
<i class="fa fa-comments fa-fw"></i>comment</button>
<button href="#" data-title="view post" onclick="changeContainer()">
<i class="fa fa-external-link fa-fw"></i></button>
</div>
</div>
</div>
</div>
<div class="grid-container-after">
<div class="box a">A</div>
<div class="box b">B</div>
</div>
</section>
</div>
</body>
I have the task of compose such a block. I could make it using CSS3 position relative position absolute.
And need to compose this block using Flexbox.
What i have got it's in the bottom.If it's possible try to use it and don't write from scratch.
.item {
position: relative;
display: -webkit-flex;
display: flex;
width: 100%;
margin-bottom: 8px;
box-shadow: 0 1px 4px rgba(41,51,57,.5);
color: #37454d;
background: #fff;
}
.item_wrapper {
width: 100%;
position: relative;
}
.image-wrapper:before {
content: "";
display: block;
padding-top: 100%;
}
.item_image {
position: absolute;
top: 0;
width: 100%;
height: 100%;
left: 0;
-webkit-transition: -webkit-transform .3s;
transition: -webkit-transform .3s;
transition: transform .3s;
transition: transform .3s,-webkit-transform .3s;
}
.image-area {
padding: 8px 6px 8px 8px;
width: 22.25%;
float: left;
}
.image-wrapper {
position: relative;
line-height: 0;
overflow: hidden;
}
.image-wrapper:hover{
-webkit-transform: scale(1.05);
transform: scale(1.05);
}
.image_gallery {
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
border-radius: 0;
margin: 0;
-webkit-transition: opacity .3s;
transition: opacity .3s;
opacity: 0;
display: block;
background: 0;
position: absolute;
cursor: pointer;
padding: 0;
border:0;
}
.flex-column {
height: 100%;
display: flex;
align-items: stretch;
}
.item_details {
position: relative;
width: 100%;
border-right: 1px solid #cdd0d2;
margin: 8px 0;
border-bottom: 0;
float: left;
padding: 0 8px 0 4px;
}
.item_name {
margin-bottom: 16px;
font-size: 20px;
display: inline-block;
width: 100%;
}
.name_copytext {
color: #005f81;
margin: 0;
max-width: calc(100% - 38px);
text-overflow: ellipsis;
width: 100%;
float: left;
text-align: left;
direction: ltr;
overflow: hidden;
white-space: nowrap;
}
.item_location {
overflow: hidden;
}
.details_paragraph {
padding-right: 0px;
margin-bottom: 16px;
line-height: 1.30;
overflow: hidden;
}
.item_dynamic-content {
display: block;
font-size: 12px;
padding: 0;
}
.item_deal {
display: flex;
display: -webkit-flex;
align-items: stretch;
-webkit-align-items:stretch;
padding: 8px;
width: 47%;
}
.item_best-details {
display: flex;
display: -webkit-flex;
-webkit-flex-direction:column;
flex-direction: column;
-webkit-justify-content:space-around;
justify-content: space-around;
-webkit-flex-wrap:wrap;
flex-wrap: wrap;
flex-grow:2;
-webkit-flex-grow:2;
clear: none;
float: none;
text-align: center;
width: 100%;
-webkit-order:3;
order: 3;
}
<article class="item">
<div class="item_wrapper">
<div class="image-area">
<div class="image-wrapper">
<img src="https://media-cdn.tripadvisor.com/media/photo-s/07/6e/64/52/hyatt-regency-santa-clara.jpg" class="item_image">
<button type="button" class="image_gallery">
</button>
</div>
</div>
<div class="flex-column">
<div class="item_details">
<div class="item_name">
<h3 class="name_copytext" title="Hyatt Regency Santa Clara">Hyatt Regency Santa Clara</h3>
</div>
<div class="item_location">
<p class="details_paragraph">Santa Clara, California, USA </p>
</div>
<div class="item_review">
<div class="details_paragraph">
<em class="rating-number">
<span class="rating-number_value">Very good</span>
</em>
<span class="review_count">(2045 reviews)</span>
</div>
</div>
</div>
<section class="item_deal">
<div class="item-link">
<div class="item_best-details">
<!-- dozen blocks-->
</div>
</div>
</section>
</div>
</div>
</article>
Here is a jsfiddle
This is the box model you must follow to do it with flexbox and with a clear structure. Each area is a container.
.Card,
.Card * {
background-color: rgba(0, 0, 0, 0.05);
margin: 8px;
}
.Card {
display: flex;
min-height: 300px;
}
.Picture {
width: 200px;
display: flex;
flex-direction: column;
}
.Picture img {
flex-grow: 1;
}
.Desc {
height: 20px;
}
.Content {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.ContentHead {
height: 20px;
}
.ContentDetail {
flex-grow: 1;
display: flex;
}
.Details {
flex-grow: 1;
}
.Side {
flex-basis: 30%;
}
<div class="Card">
<div class="Picture">
<img src="" alt="">
<div class="Desc"></div>
</div>
<div class="Content">
<div class="ContentHead"></div>
<div class="ContentDetail">
<div class="Details"></div>
<div class="Side"></div>
</div>
</div>
</div>
How to make properly such navigation bar, especially this two intersecting lines. I know that I can use transform: skewX(10deg); for rotating this vertical line, but not sure am I ok with whole html&css
HTML:
<main>
<div class="rounded-rectangle">
<ul class="top">
<li>
<button>text</button>
</li>
<li>
<button>text</button>
</li>
</ul>
<ul class="bottom">
<li>
<button>text</button>
</li>
<li>
<button>text</button>
</li>
</ul>
</div>
</main>
Fiddle
You could use pseudo elements of the container to draw the intersecting lines.
html,
body {
height: 100%;
}
body {
display: flex;
flex-direction: row;
font-family: 'Raleway', sans-serif;
background-color: #e24d3d;
}
main {
flex-grow: 1;
}
ul li {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
list-style: none;
text-transform: uppercase;
font-size: 30px;
}
button {
background-color: transparent;
border: none;
color: white;
padding: 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 2.5em;
font-family: 'Raleway', sans-serif;
text-transform: uppercase;
}
button:focus {
outline: -webkit-focus-ring-color auto 0px;
}
ul.top {
display: flex;
justify-content: space-around;
height: 50%;
}
ul.top div:nth-last-child(1) {
border-right: 1px solid #FFF;
}
ul.bottom {
display: flex;
justify-content: space-around;
height: 50%;
}
.rounded-rectangle {
background-color: rgba(128, 213, 226, 0.4);
height: 320px;
max-width: 520px;
border-radius: 10px;
margin: auto;
position: relative;
}
.rounded-rectangle:before, .rounded-rectangle:after {
content: '';
position: absolute;
background: #fff;
}
.rounded-rectangle:before {
top: 50%;
height: 1px;
left: 0; right: 0;
}
.rounded-rectangle:after {
left: 50%;
width: 1px;
top: 0; bottom: 0;
transform: rotate(10deg);
}
ul {
padding: 0;
margin: 0;
}
<main>
<div class="rounded-rectangle">
<ul class="top">
<li>
<button>text</button>
</li>
<li>
<button>text</button>
</li>
</ul>
<ul class="bottom">
<li>
<button>text</button>
</li>
<li>
<button>text</button>
</li>
</ul>
</div>
</main>