'how to set p, h1, ul on same height in flexbox/grid
I have the following code: https://jsfiddle.net/yedovc7w/
body,
p,
h1,
ul {
margin: 0;
padding: 0;
}
.content {
display: flex;
/* grid-template-columns: 1fr 1fr; */
}
.left,
.right {
border: 2px black solid;
height: 400px;
}
.right {
width: 100%;
}
.middle {
width: 100%;
}
.left {
width: 100%;
}
<div class="content">
<div class="left">
<p>xLorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium sit deserunt nisi. Qui provident sit minima eius. Voluptatem ea perspiciatis obcaecati iure. Sequi adipisci rerum laudantium voluptates id quod minus.Schlüsselqualifikationen</p>
</div>
<div class="middle">
<ul>
<li class="nav-desktop" role="presentation">
<a href="/">Home</a>
</li>
</ul>
</div>
<div class="right">
<h1>Hi ich bin hier</h1>
<p>xLorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium sit deserunt nisi. Qui provident sit minima eius. Voluptatem ea perspiciatis obcaecati iure. Sequi adipisci rerum laudantium voluptates id quod minus.Schlüsselqualifikationen</p>
</div>
</div>
I want that the text as well as the h1 and the heading start at the same "height". With same height I mean, that all start at the top of the div.
How can I achieve this?
Also the dot of the ul element (I want to have this "dot"!) moves to the wrong box. I want this to be in the box where the li is.
I want to align the items at the red line or in other words - same line
Solution 1:[1]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body, p, h1, ul{
margin: 0;
padding: 0;
}
.content {
display: flex;
/* grid-template-columns: 1fr 1fr; */
}
.left, .right {
border: 2px black solid;
height: 400px;
}
.right {
width: 100%;
}
.middle {
width: 100%;
}
.left {
width: 100%;
}
</style>
</head>
<body>
<div class="content">
<div class="left"></br></br>
<p>xLorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium sit deserunt nisi. Qui provident sit minima eius. Voluptatem ea perspiciatis obcaecati iure. Sequi adipisci rerum laudantium voluptates id quod minus.Schlüsselqualifikationen</p>
</div>
<div class="middle"></br></br>
<ul>
<li class="nav-desktop" role="presentation" style="margin-left: 20px">
<a href="/">Home</a>
</li>
</ul>
</div>
<div class="right">
<h1>Hi ich bin hier</h1>
<p>xLorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium sit deserunt nisi. Qui provident sit minima eius. Voluptatem ea perspiciatis obcaecati iure. Sequi adipisci rerum laudantium voluptates id quod minus.Schlüsselqualifikationen</p>
</div>
</div>
</body>
</html>
All I added was double br in the start of the middle and left divs, as well as a margin-left of 20px for the link in the middle section.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rani Giterman |
