Safari does not allow absolute position a element when using column-count - html

I want to style divs in a container and give it an position:absolute.
The parent container uses column-count=3 to layout the elements.
This works fine in Chrome and Firefox, but Safari does not position the element right.
This is how it looks like in Chrome and Firefox:
This is Safari:
html,
body {
margin: 0px;
min-height: 100%;
height: 100%;
}
.app {
display: flex;
}
.list-wrapper {
margin-top: 25px;
}
ul li:first-child {
margin-top: 0px;
}
ul {
margin: 0;
padding: 0;
list-style-type: none;
column-gap: 0px;
column-count: 3;
column-width: 200px;
}
li {
border: 1px solid black;
margin: 4px;
padding: 20px;
overflow: hidden;
break-inside: avoid-column;
}
h1 {
height: 30px;
min-height: 30px;
line-height: 30px;
width: 100%;
margin: 0px;
}
li h1::before {
content: "";
position: absolute;
width: 24px;
height: 24px;
border-radius: 50%;
transform: translateY(-42px);
background: #7fb8ff;
border: 3px solid #0072ff;
box-shadow: 0 0 4px #aaa;
}
<div class="app">
<div class="list-wrapper">
<ul>
<li>
<div>
<h1>Title 1</h1>
<p>Just some content</p>
</div>
</li>
<li>
<div>
<h1>Title 2</h1>
<p>Just some content</p>
</div>
</li>
<li>
<div>
<h1>Title 3</h1>
<p>Just some content</p>
</div>
</li>
<li>
<div>
<h1>Title 4</h1>
<p>Just some content</p>
</div>
</li>
<li>
<div>
<h1>Title 5</h1>
<p>Just some content</p>
</div>
</li>
</ul>
</div>
</div>
Anyone any idea how I could fix this?

I havent tested this but it may work wrap the content inside the li element in a div and the put the "just some content" in a p element
<div class="app">
<div class="list-wrapper">
<ul>
<li>
<div>
<h1>Title 1</h1>
<p>jsut some content</p>
</div>
</li>
<li>
<div>
<h1>Title 2</h1>
<p>jsut some content</p>
</div>
</li>
<li>
<div>
<h1>Title 3</h1>
<p>jsut some content</p>
</div>
</li>
<li>
<div>
<h1>Title 4</h1>
<p>jsut some content</p>
</div>
</li>
<li>
<div>
<h1>Title 5</h1>
<p>jsut some content</p>
</div>
</li>
<li>
<div>
<h1>Title 6</h1>
<p>jsut some content</p>
</div>
</li>
</ul>
</div>
</div>

Related

How to remove insane gap between my sections

there is a huge gap between my sections and I have no clue why i have tried adding padding in the form of #me { padding-bottom: 150px; } but i tried with different numbers and i see a difference when making the gap longer but when i try going negitive, it cant really seem to have an affect on whats actually going on.
here is my code for HTML
.container {
width: 100%;
height: 100%;
background: #12182b;}
.me-section {
text-align: left;
padding-left: 850px;
height: 100vh;
margin-top: 320px;}
.me-section h1 {
color: #6dffe7;
font-size: 20px;
margin: 0px;}
.about-section {
text-align: left;
padding-left: 850px;
height: 100vh;
margin-top: 320px;}
.about-section h1 {
color: #6dffe7;
font-size: 20px;
padding-top: 150px;}
<div class="container">
<img src="logo.png" class="logo">
<div class="header">
<nav class="navbar">
<ul>
<div class="download-btn">
<li>About</li>
<li>Work</li>
<li>Contact</li>
<li>Resume</li>
</div>
</ul>
</nav>
<section id="me">
<div class="me-section">
<h1 class="my-name-after">Hi, my name is</h1>
<h2 class="header-name">Alberto Aday.</h2>
<h2 class="header-rest">I build on the web.</h2>
<p>I'm an aspiring software engineer. I like to build<br>websites. Back-end development is currently <br>progress.</p>
</div>
</section>
<section id="about">
<div class="about-section">
<h1>About me.</h1>
</div>
</section>
<section id="work">
<div class="work-section">
<h1>Work</h1>
</div>
</section>
<section id="contact">
<div class="contact-section">
<h1>Contact</h1>
</div>
</section>
</div>
I went ahead and removed the massive margins, which yes, did change the position of where things were but also created a ton of whitespace.
.container {
width: 100%;
height: 100%;
background: #12182b;}
.me-section {
text-align: left;
padding-left: 850px; }
.me-section h1 {
color: #6dffe7;
font-size: 20px;
margin: 0px;}
.about-section {
text-align: left; }
.about-section h1 {
color: #6dffe7;
font-size: 20px;}
<div class="container">
<img src="logo.png" class="logo">
<div class="header">
<nav class="navbar">
<ul>
<div class="download-btn">
<li>About</li>
<li>Work</li>
<li>Contact</li>
<li>Resume</li>
</div>
</ul>
</nav>
<section id="me">
<div class="me-section">
<h1 class="my-name-after">Hi, my name is</h1>
<h2 class="header-name">Alberto Aday.</h2>
<h2 class="header-rest">I build on the web.</h2>
<p>I'm an aspiring software engineer. I like to build<br>websites. Back-end development is currently <br>progress.</p>
</div>
</section>
<section id="about">
<div class="about-section">
<h1>About me.</h1>
</div>
</section>
<section id="work">
<div class="work-section">
<h1>Work</h1>
</div>
</section>
<section id="contact">
<div class="contact-section">
<h1>Contact</h1>
</div>
</section>
</div>
The issue is your height:
.me-section {
text-align: left;
padding-left: 850px;
height: 100vh; /* <-------------- */
margin-top: 320px;
}
Changing it to 50 or 60 it looked a lot better!

Placing items horizontally on Page [duplicate]

This question already has answers here:
Text floating in block next to image
(6 answers)
Closed 2 years ago.
I am new to html + css and I can't seem to figure out how you place items horizontally despite reading a couple articles. What I am going for is having two lines of text on the right side of my image. Currently I have everything placed vertically.
Html:
#content {
max-width: 640px;
margin: 0 auto;
padding: 64px 24px;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
```
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
</body>
I am not sure if I am sharing everything I need too, Here's the GitHub repo with all the code if you need it.
You can use display: flex; property.
/* ↓ new styling ↓ */
.section-horizontal {
display: flex;
}
.description {
margin-left: 32px;
}
/* your styling */
#content {
max-width: 640px;
margin: 0 auto;
padding: 64px 24px;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
<div id="content">
<div class="section section-horizontal"> <!-- class for flexbox -->
<img src="Images/Logo.png" class="img">
<div class="description"> <!-- add this block to align headings vertically -->
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
try to get in touch with the flex property. It will make things alot more simple :)
html:
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<div class="flex">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
</div>
</div>
</body>
css:
.flex {
display: flex;
}
You can do with flexbox like this
#content {
max-width: 640px;
margin: auto;
padding: 64px 24px;
display:flex;
flex-wrap:wrap;
justify-content: space-evenly;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
</body>

How can I get the text to be at the bottom of an image?

I have an unordered list of images that transition in the format below and I want each image to have a text overlay at the bottom of it. How should I style the paragraph div correctly to get the desired result? The text keeps appearing at the top.
<li data-transition="fade">
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<div style="bottom: 10px; left: 19px;font-size: 13px;">
<p>Some text at the bottom</p>
</div>
</li>
Use the correct HTML element - the <figure> element.
Whilst all the other answers do provide a styling solution - the better approach is to use the correct html element - which in this case is the HTML5 figure element. This has the semantic structure of being a container to wrap around an image and a text element - the figcaption - which can either be the first child (ie - above the image) or the last child -ie - below the image.
Then you can style the figcaption to be on top of the image if desired (as noted in one of the other solutions - position:relative on the parent figure element and position absolute on the figcaption).
.list-item {
list-style-type: none;
text-align: center;
}
figure {
display: inline-block;
position: relative;
}
figcaption{
background-color: wheat;
position: absolute;
bottom: 4px;
left: 0;
right:0
}
<li class="list-item" data-transition="fade">
<figure>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<figcaption>Some text at the bottom</figcaption>
</figure>
<figure>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<figcaption>Some text at the bottom</figcaption>
</figure>
<figure>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<figcaption>Some text at the bottom</figcaption>
</figure>
</li>
Use correct style
When you use bottom: 10px; left: 19px; you need to add position: absolute; or relative.
The <p> tag have default margin so I write margin: 0; and thats all.
Preferable use class for style, and I add a little things.
.item {
list-style-type: none;
text-align: center;
}
.wrap {
display: inline-block;
text-align: center;
}
.text {
margin: 0;
position: relative;
top: -26px;
background-color: antiquewhite;
}
<li class="item" data-transition="fade">
<div class="wrap">
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<p class="text">Some text at the bottom</p>
</div>
<div class="wrap">
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<p class="text">Some text at the bottom</p>
</div>
<div class="wrap">
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<p class="text">Some text at the bottom</p>
</div>
</li>
Try this:
ul {
list-style: none;
}
.container {
display: inline-block;
text-align: center;
}
.text {
margin: 0;
}
<ul>
<li>
<div class=container>
<p class="text">Some text</p>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
</div>
</li>
<li>
<div class="container">
<p class="text">Some text</p>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
</div>
</li>
<li>
<div class="container">
<p class="text">Some text</p>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
</div>
</li>
</ul>
Set position:relative on the parent li and position:absolute on the text container
.imgList li {
/*Child items will be positioned relative to this*/
position:relative;
}
.imgList .title {
/*Postition relative to parent li*/
position:absolute;
bottom: 10px;
font-size: 13px;
left:19px;
background-color: rgba(255,255,255,0.5)
}
<ul class="imgList" >
<li data-transition="fade">
<img src="https://www.fillmurray.com/300/300">
<div class="title" >
<p>Some text at the bottom</p>
</div>
</li>
</ul>
Simply, you can use this example:
*, *:before, *:after {
margin: 0;
padding:0;
}
div {
position: relative;
list-style: none;
margin: 0;
padding:0;
text-align:center;
}
div img {
margin: 0;
padding:0;
position: relative;
}
p {
position: absolute;
bottom: 0;
width: 100%;
left:0;
background:red;
margin: 0;
color: #ffffff;
}
.main {
display:flex;
}
<div class="main">
<div>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<p>Some text at the bottom</p>
</div>
<div>
<img src="https://i217.photobucket.com/albums/cc312/mastersig/Avitars/For%20Me/C_D_A.png">
<p>Some text at the bottom</p>
</div>
</div>

White space between <h3> <h4> and <p> tags

My code is simple here, although I still can't figure out how to remove the white gap that is in between each tag. You can see it between the h3 and h4 tags with the background colors. How do I get rid of this space?
.realEstatePricing h3 {
Background: lightblue;
height: 40px;
}
.realEstatePricing h4 {
Background: lightgrey;
}
<section class="realEstatePricing">
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3 class="text-center">Photo Package</h3>
<h4 class="text-center">$99</h4>
<p>description 1</p>
<p>description 1</p>
<p>description 1</p>
<p>description 1</p>
</div>
</div>
</div>
</section>
As a response to the other answers you can do this:
.realEstatePricing h3 {
background-color: lightblue;
height: 40px;
margin-bottom: 0;
}
.realEstatePricing h4 {
background-color: lightgrey;
margin-top: 0;
}
This way your overall left and top margins will remain in their current state.
You can do it by adding margin to 0 for both of them
.realEstatePricing h3 {
Background: lightblue;
height: 40px;
margin:0;
}
.realEstatePricing h4 {
Background: lightgrey;
margin:0;
}
<html>
<head>
</head>
<body>
<section class="realEstatePricing">
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3 class="text-center">Photo Package</h3>
<h4 class="text-center">$99</h4>
<p>description 1</p>
<p>description 1</p>
<p>description 1</p>
<p>description 1</p>
</div>
</div>
</div>
</section>
</body>
</html>

How to get 'four corner' alignment with floated divs

Ok so my project requires my divs to be floated because I would like to place text neatly to the side of them. I can get my divs to float left and right as needed, but as you see from the snippet(even though it's not what you'd get from a browser since the dimensions are off), the two divs at the bottom I need to be near the top in order to make a perfect scquare with the two left-floated divs. Below is what I'm looking for:
.clear {
clear: both;
}
#centerbar {
width: 100%;
height: calc(100vh - 150px);
background-color: black;
float: left;
}
#centerbar h1 {
text-align: center;
color: white;
}
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
font-family: courier;
font-size: 19px;
color: white;
}
#container {
min-height: 100%;
margin-bottom: -150px;
width: 100%;
}
#container:after {
content: "";
display: block;
}
#content {
display: flex;
margin: 0 auto;
width: 800px;
flex-wrap: wrap;
justify-content: center;
}
.box {
height: 200px;
}
.fltlt {
float: left;
margin-right: 50px;
}
.fltrt {
float: right;
margin-right: 50px;
}
<div class="container">
<div id="nav">
<ul>
<li>Home
</li>
<li>Works
</li>
<li>About
</li>
</ul>
</div>
<div class="clear"></div>
<div id="centerbar">
<h1>Sample Layout</h1>
<div class="box">
<img src="gold.jpg" alt="The Color Gold" class="fltlt">
<p>This is some sample text</p>
</div>
<div class="clear"></div>
<div class="box">
<img src="grey.jpg" alt="The Color Grey" class="fltlt">
<p>This is some sample text</p>
</div>
<div class="box">
<img src="orange.jpg" alt="The Color Orange" class="fltrt">
<p>This is some sample text</p>
</div>
<div class="box">
<img src="red.png" alt="The Color Red" class="fltrt">
<p>This is some sample text</p>
</div>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub">Lorem Ipsum</div>
<div class="sub">Lorem Ipsum</div>
<div class="sub">Lorem Ipsum</div>
</div>
</div>
I recommend to not use float for layout, and since you started out with flex, use it all the way.
Bonus: A clean, simple and readable structure of both CSS and markup.
.container .row {
display: flex;
flex-wrap: wrap;
}
.row .box {
width: 50%;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 10px;
}
.box img {
width: 100px;
margin-right: 10px;
}
<div class="container">
<div class="row">
<div class="box">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="">
<p>Some paragraph here</p>
</div>
<div class="box">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="">
<p>Some paragraph here</p>
</div>
<div class="box">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="">
<p>Some paragraph here</p>
</div>
<div class="box">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="">
<p>Some paragraph here</p>
</div>
</div>
</div>
Here is what you are looking for(I made it from the start):
.box {
float: left;
position: relative;
width: 50%;
margin-bottom: 10px;
}
.container .flex {
display: flex;
align-items: center;
}
.container p {
margin-left: 5px;
}
<div class="container">
<div class="row">
<div class="box">
<div class="flex">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="" width="100">
<p>Some paragraph here</p>
</div>
</div>
<div class="box">
<div class="flex">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="" width="100">
<p>Some paragraph here</p>
</div>
</div>
<div class="box">
<div class="flex">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="" width="100">
<p>Some paragraph here</p>
</div>
</div>
<div class="box">
<div class="flex">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSr2zmmalj8xwazqph9jB97VW8MgfrfJ_ThJt9iTGKGMNl-7dp7mKnfvg4" alt="" width="100">
<p>Some paragraph here</p>
</div>
</div>
</div>
</div>