How to position background-image between two texts - html

I want to position a text and image like this:
This is what I have now
http://jsfiddle.net/vzovk7xd/
<section class="feature">
<div class="container">
<article class="feature-item design">
<h2>Web Design</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rhoncus, lacus ac commodo volutpat, felis odio pulvinar enim, non dapibus mauris nulla sed ipsum.</p>
READ MORE
</article>
<article class="feature-item media">
<h2>Social Media</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rhoncus, lacus ac commodo volutpat, felis odio pulvinar enim, non dapibus mauris nulla sed ipsum.</p>
READ MORE
</article>
<article class="feature-item apps">
<h2>Mobile Apps</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rhoncus, lacus ac commodo volutpat, felis odio pulvinar enim, non dapibus mauris nulla sed ipsum.</p>
READ MORE
</article>
</div>
</section>
CSS
.feature {
margin-top: 100px;
text-align: center;
line-height: 25px;
}
.feature-item {
width: 33.3%;
float: left;
}
.design {
background: url(https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png) no-repeat center center;
}

Don't set background image to your .design div, put another div between the heading and paragraph, give it width and height, and set background image to that div.
<article class="feature-item design">
<h2>Web Design</h2>
<div class="image"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rhoncus, lacus ac commodo volutpat, felis odio pulvinar enim, non dapibus mauris nulla sed ipsum.</p>
READ MORE
</article>
css
.image { width: 100%; height: 140px; background: url(https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png) no-repeat center center; }
https://jsfiddle.net/vzovk7xd/1/

add this css:
.design, .media, .apps {
background: url(https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png) no-repeat top center;
background-position:75px 90px;
}
.feature-item p {margin-top:200px}
http://jsfiddle.net/vzovk7xd/6/

Don't put it as background (if you want to do that, you need to set width and height for .design box).. instead, add another div element between h2 and p elmenets:
<h2>Web Design</h2>
<div class="design"><img src="https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png"/></div>
<p>Lorem ipsum dolor sit amet</p>
Working fiddle: http://jsfiddle.net/vzovk7xd/7/

You try to put an inline (in the elments flow order) element with the background style (out of the elements flow)... Better use an inline element to present it like an inline element.
Solution A: (modify CSS, remove background)
.feature-item h2:after {
content: url('https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png');
margin: 24px 0 0 0;
display: inline-block;
}
http://jsfiddle.net/vzovk7xd/9/
Solution B: (modify HTML)
<article class="feature-item design">
<h2>Web Design</h2>
<figure></figure>
figure {
background: url(https://31.media.tumblr.com/avatar_b0a905e3eb32_128.png)
no-repeat center center;
width: 100px;
height: 100px;
}
http://jsfiddle.net/vzovk7xd/3/

Related

Background color of sidebars, HTML,CSS

I would like to ask you something that has been bothering me for a while. I currently learn HTML and CSS and we got this homework where we have to create a blog that has one article in the middle and two sidebars on the right, the background color of the site should be gray. the problem is that the main article and the two sidebars should have a white background color, so when I change the article's background color to white, it automatically takes control over 75% of the website, even outside the article. here is a screenshot.
What I am trying to make
https://f.v1.n0.cdn.getcloudapp.com/items/0k300n0O0J0c1l1B3K2J/blog-1.png
What I get when I change the background color of the sidebars to white
https://ctrlv.sk/WF4e
.main-image {
height: 260px;
width: 670px;
}
.main {
text-align: center;
padding: 40px;
margin-top: -10px;
}
.main2 {
background-color: white;
}
body {
background-color: rgb(243, 243, 243)
}
.line {
margin-top: 50px;
}
hr {
margin-top: -20px;
}
.back {
background-color: white;
}
.box-post {
background: white;
margin-left: 70px;
}
.sideimage {
float: right;
margin-top: -340px;
width: 350px;
margin-right: 100px;
display: block;
}
.sidetext {
text-align: right;
margin-top: -180px;
margin-right: 160px;
}
<title>Blog</title>
<link rel="stylesheet" href="styles.css">
<header>
<div class="main2">
<h1 class="main">
<strong>Dopetrope</strong>
</h1>
</div>
<hr>
</header>
<section id="main">
<article class="box-post">
<img class="main-image" src="pic01.jpg" alt="obrazocek">
<header>
<h1>Right sidebar</h1>
<h3>Lorem ipsum dolor sit amet feugiat</h3>
<div>
</div></header>
<p>
</p><section class="box">
<img class="sideimage" src="pic09.jpg">
<h1 class="sidetext2">Sed etiam lorem nulla</h1>
<p class="sidetext">
Lorem ipsum dolor sit amet sit veroeros <br>
sed amet blandit consequat veroeros <br>
lorem blandit adipiscing et feugiat <br>
phasellus tempus dolore ipsum lorem <br>
dolore.
</p>
</section>
<p>
Vestibulum scelerisque ultricies libero id hendrerit. Vivamus malesuada quam faucibus ante <br>
dignissim auctor hendrerit libero placerat. Nulla facilisi. Proin aliquam felis non arcu molestie at <br>
accumsan turpis commodo. Proin elementum, nibh non egestas sodales, augue quam aliquet est, <br>
id egestas diam justo adipiscing ante. Pellentesque tempus nulla non urna eleifend ut ultrices nisi <br>
faucibus. <br><br><br>
Praesent a dolor leo. Duis in felis in tortor lobortis volutpat et pretium tellus. Vestibulum ac ante <br>
nisl, a elementum odio. Duis semper risus et lectus commodo fringilla. Maecenas sagittis convallis <br>
justo vel mattis. placerat, nunc diam iaculis massa, et aliquet nibh leo non nisl vitae porta lobortis, <br>
enim neque fringilla nunc, eget faucibus lacus sem quis nunc suspendisse, nec lectus sit amet <br>
augue rutrum vulputate ut ut mi. Aenean elementum, mi sit amet portittor lorem ipsum dolor sit <br>
amet, consecteur adipiscing elit. Lorem ipsum dolor sir amet nullam consequat feugiat dolore <br>
tempus.
</p>
</article>
</section>
Any idea on how to change this? I hope you understand what I am trying to acheive here. Also please don't mind the code too much if it's wrong, I am still pretty new to this stuff :D
I think you may need to change your layout , by using one DIV on the left, and two DIVs on the right, as follows
.main {
text-align: center;
padding: 40px;
margin-top: -10px;
border-bottom:1px solid #DDDDDD;
}
.main2 {
background-color: white;
}
body {
background-color: rgb(243, 243, 243);
margin:0;
}
.container {
width:100%;
padding:20px;
}
.leftbox {
width:68%;
float:left;
background:#FFFFFF;
}
.image1 {
padding:0px;
background-image:url("https://i.stack.imgur.com/nhPHk.jpg");
height:160px;"
}
.image2 {
padding:0px;
background-image:url("https://i.stack.imgur.com/Vqklg.jpg");
height:50px;
}
.leftboxcontent {
padding:20px;
}
.middlespace {
width:3%;
float:left;
}
.rightbox {
width:25%;
float:left;
}
.rightboxcontent1 {
background-color:#FFFFFF;
width:100%;
}
.rightboxcontent1a {
padding:20px;
}
.rightboxcontent2 {
background-color:#FFFFFF;
width:100%;
}
.rightboxcontent2a {
padding:20px;
}
<title>Blog</title>
<body>
<div class="main2">
<h1 class="main">
<strong>Dopetrope</strong>
</h1>
</div>
<div class=container>
<div class=leftbox>
<div class=image1> </div>
<div class=leftboxcontent>
<h1>Right sidebar</h1>
<h3>Lorem ipsum dolor sit amet feugiat</h3>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
<h4>Lorem ipsum dolor sit amet feugiat</h4>
</div>
<div> </div>
</div>
<div class=middlespace> </div>
<div class=rightbox>
<div>
<div class=image2> </div>
<div class=rightboxcontent1>
<div class=rightboxcontent1a>
TESTTEST<BR>TESTTEST<BR>
TESTTEST<BR>TESTTEST<BR>
TESTTEST<BR>TESTTEST<BR>
TESTTEST<BR>TESTTEST<BR>
TESTTEST<BR>TESTTEST<BR>
TESTTEST<BR>TESTTEST<BR>
</div>
</div>
</div>
<br><br>
<div>
<div class=rightboxcontent2>
<div class=rightboxcontent2a>
TESTTEST2<BR>TESTTEST2<BR>
TESTTEST2<BR>TESTTEST2<BR>
</div>
</div>
</div>
</div>
</div>
</body>
It is good practise to start with a strong structure before filling it with content. If you have a good structure, then you have less debugging. Something like the template below.
Tip. The display:flex is more flexible then the float:left
* {
margin: 0;
box-sizing: border-box;
}
#header {
width: 100%;
}
#main {
float: left;
width: 70%;
}
#aside {
float: left;
width: 30%;
}
#footer {
clear: both;
width: 100%;
}
/* for test purpose only */
.test {
height: 80px;
border: 1px solid orange;
}
<header id="header" class="test">
</header>
<section id="main" class="test">
<article>
</article>
</section>
<aside id="aside" class="test">
</aside>
<footer id="footer" class="test">
</footer>

responsive columns all same height with heading, paragraph, button all same height

I'm struggling to achieve responsive column. Currently all columns are not the same height. When the screen gets smaller, the paragraphs are not the same level, I am trying to make them the same level no matter what screen size. My next problem is the button will also not be the same level in all columns.
Bellow is currently my HTML:
<div class="container">
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" /> <h2>Fencing and Gates</h2>
<h2>test heading text long</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. Maecenas id leo at elit vestibulum sagittis at in ex. Cras vulputate laoreet dictum. Vestibulum nec quam placerat, blandit orci in, hendrerit ante. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text longer </h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text longer longer </h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>Block Paved Driveways and Paths</h2>
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. Maecenas id leo at elit vestibulum sagittis at in ex. Cras vulputate laoreet dictum. Vestibulum nec quam placerat, blandit orci in, hendrerit ante. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
<div class="section">
<img src="http://via.placeholder.com/500x400" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
<h2>test heading text</h2 >
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vestibulum faucibus turpis, sed blandit mauris bibendum sit amet. Praesent congue enim at orci dapibus accumsan. </p>
Learn more
</div>
</div>
Below is my CSS:
.container:after { /*clear float*/
content: "";
display: table;
width: 100%;
clear: both;
}
.container {
margin-left: 100px;
margin-right: 100px;
text-align: center;
padding-top: 30px;
}
.section {
float: left;
width: 33.3333%;
padding-bottom: 50px;
border: 1px solid;
box-sizing: border-box;
display: table-cell;
}
.section p {
padding-bottom: 50px;
text-align: center;
font-family: "Montserrat", sans-serif;
font-size: 19px;
padding-left: 25px;
padding-right: 25px;
}
.section h2 {
text-align: center;
font-family: "Slabo 27px", serif;
font-size: 24px;
font-weight: 700;
text-align: center;
padding-left: 25px;
padding-right: 25px;
}
#media (max-width: 768px) {
.section {
float: none;
width: auto;
}
}
below is a js fiddle of what I currently have
https://jsfiddle.net/b147rmdh/
Any help on this would be greatly appreciated!
You need to specify a height for each column for them to all be the same height. If you don't then the columns will size themselves based on the amount of content they contain (which is currently what is happening in your code). More specifically relating to your code, if you add a specific height to your .section class, then all the columns should be the same height.
Once you have done this, you could use absolute positioning on all of the elements within the columns (the headers, paragraphs, buttons, etc) so that they all line up. If you aren't very familiar with absolute positioning and the position property in general, here is a great reference that explains positioning well. Definitely recommend giving it a read and taking the time to get a good understanding of positioning since it's one of the most fundamental CSS skills.
I'd suggest a Flexbox with wrapping.
.container {
display: flex;
flex-wrap: wrap;
}
.section {
width: 33.3333%;
}
Once you've done that, you can use a similar method vertically if you wrap the upper content in one element and keep the button separate. Set your flex-direction to column and justify-content to space-between.

Aligning elements within a list element

I have a list of n items.
I'm trying to align the a element having child img, next to sibling p element.
I've tried setting both to display:inline-block, but I don't see any change. My code looks like this:
<li>
<h3>Header 3</h3>
<img src="example.img" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate interdum lacus in hendrerit. Donec libero metus, maximus sit amet.</p>
</li>
My goal is to create a sort of panel where the a element is to the left with the text next to it, and the h3 centered in that same panel.
<li>
<h3>Header 3</h3>
<a href="#">
<img src="example.img" alt="">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate interdum lacus in hendrerit. Donec libero metus, maximus sit amet.</p>
</li>
I didn't understand what your question goal. But, tell me if my answer was wrong :)
li{
list-style: none;
}
h3{
text-align: center;
}
img{
float: left;
}
p{
text-align: right;
}
<li>
<h3>Header 3</h3>
<img src="example.img" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate interdum lacus in hendrerit. Donec libero metus, maximus sit amet.</p>
</li>
use display:inline-block in a and p and set some width, use text-align:center in h3
body,
h3,
p {
margin: 0;
font-size:16px /* restore font-size inline-block fix*/
}
h3 {text-align: center}
ul {
margin: 0;
padding: 0;
font-size: 0
/*inline-block fix gap*/
}
li {
background: red;
}
a,
li,
p {
display: inline-block;
vertical-align: top;
width: 50%
}
img {
width: 100%;
display: block
}
<ul>
<li>
<h3>Header 3</h3>
<a href="#">
<img src="//lorempixel.com/100/100" alt="">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate interdum lacus in hendrerit. Donec libero metus, maximus sit amet.</p>
</li>
<li>
<h3>Header 3</h3>
<a href="#">
<img src="//lorempixel.com/100/100" alt="">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate interdum lacus in hendrerit. Donec libero metus, maximus sit amet.</p>
</li>
</ul>

What to do to align text as shown in the image using HTML and CSS?

I'm trying to align a block of text so it looks like in the image. However, without acceptable result. The text is located in the floating div which is repeating. Same divisions are floating next to each other.
My HTML code:
<div id="bottomPanel">
<div class="bottomItem">
<img src="image.png" alt="mouse" class="imgBottom">
Lorem ipsum dolor sit amet
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
My CSS code:
#bottomPanel {
float: left;
width: 100%;
text-align: center;
}
.bottomItem {
float: left;
width: 100%;
margin-top: 10px;
background-color: #e6e6e6;
}
.imgBottom {
float: left;
padding-top: 25px;
padding-left: 14px;
}
.item_bottomDesc {
float: left;
font-family: Arial;
font-weight: bold;
font-size: 12px;
text-decoration: none;
color: #133855;
padding-top: 42px;
padding-left: 18px;
display: block;
}
.item_bottomAbout {
float: left;
font-family: Arial;
font-size: 12px;
width: 376px;
height: auto;
text-align: justify;
display: block;
padding-top: 50px;
color: #7b7a79;
}
This is how the elements should look like:
The text I can't align properly is the long one.
Division has 100% width which is approx. 774px. bottomPanel is a div where all floating .bottomItem are located.
Any ideas?
So not much wrong here overall. Just that you have a few extra things you don't need.
Namely, bottomDesc and bottomAbout do not need to be floated, and the padding-top for those two elements need adjusting too.
I have also added an explicit width/height for the image, feel free to adjust as needed but it's a good idea to define it. I also replaced its padding with appropriate margins.
Finally, I removed the #bottomPanel styles altogether - again float is not needed here, and width:100% is default anyway. Also, the text-align:center was unnecessary.
Here's the revised code for you to look at:
.bottomItem {
float: left;
width: 100%;
margin-top: 10px;
background-color: #e6e6e6;
}
.imgBottom {
float: left;
margin: 14px;
width: 100px;
height: 100px;
}
.item_bottomDesc {
font-family: Arial;
font-weight: bold;
font-size: 12px;
text-decoration: none;
color: #133855;
padding-top: 14px;
padding-left: 18px;
display: block;
}
.item_bottomAbout {
font-family: Arial;
font-size: 12px;
width: 376px;
height: auto;
text-align: justify;
display: block;
}
<div id="bottomPanel">
<div class="bottomItem">
<img src="http://placehold.it/100x100" alt="mouse" class="imgBottom">
Lorem ipsum dolor sit amet
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
Instead of float i suggest you use flexbox for this, and you dont have to use padding to get vertical align.
.bottomItem {
display: flex;
flex-direction: row;
align-items: center;
margin: 10px;
}
.right {
max-width: 60%;
margin: 0 10px;
}
<div id="bottomPanel">
<div class="bottomItem">
<img src="http://placehold.it/150x150">
<div class="right">
Lorem ipsum dolor sit amet
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
<div class="bottomItem">
<img src="http://placehold.it/150x150">
<div class="right">
Lorem ipsum dolor sit amet
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
<div class="bottomItem">
<img src="http://placehold.it/150x150">
<div class="right">
Lorem ipsum dolor sit amet
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
</div

Issue with height:auto and Flexbox

I'm trying to setup a section of my page with 3 columns using Flexbox.
The 3 columns are set up just fine, the issue I am having is with the section1 div not being as tall as the children elements.
I have tried height: auto, height:100%, overflow: auto, overflow:visible, etc. The only time the section1 div changes height is when I specifically state a pixel height. It seems as though the flexbox items are acting as floats so I tried a clear:both to no avail.
I have searched both stackoverflow and other sites and have not found an answer which leads me to believe it is something I am doing wrong with flexbox.
body {
background: lightgrey;
}
.body {
position: relative;
width: 75% /* 747.75px */;
margin: auto;
top: -3.5em;
background-color: white;
border-top: 3px solid #ff8400;
}
.top-border {
display: block;
position: relative;
top: 2em;
border-top: 1px solid #eef3f0;
width: 95%;
left: 2.5%;
}
.section1 {
position: relative;
display: flex;
justify-content: space-around;
top: 5em;
height: auto;
}
<div class="body">
<div class="top-border"></div>
<div class="section1">
<div class="what-i-do">
<img class="what-i-do-icon" src="images/what-i-do.png" />
<h1 class="what-i-do-title">What I Do</h1>
<p class="what-i-do-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu,
a consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
<p class="view-more-btn">View More</p>
</div>
<div class="development">
<img class="development-icon" src="images/development.png" />
<h1 class="development-title">Development</h1>
<p class="development-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu,
a consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
</div>
<div class="design">
<img class="design-icon" src="images/design.png" />
<h1 class="design-title">Design</h1>
<p class="design-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu, a
consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
</div>
</div>
</div>
See Relative positioning
Once a box has been laid out according to the normal flow or
floated, it may be shifted relative to this position. This is called
relative positioning. Offsetting a box (B1) in this way has no effect on the box (B2) that follows: B2 is given a position as if B1
were not offset and B2 is not re-positioned after B1's offset is
applied. This implies that relative positioning may cause boxes to
overlap.
Here you don't want to shift a single box, you want it to push following content too. Then, you should use margins for that.
body {
background: lightgrey;
}
.body {
width: 75% /* 747.75px */;
margin: auto;
margin-top: -3.5em;
background-color: white;
border-top: 3px solid #ff8400;
}
.top-border {
top: 2em;
border-top: 1px solid #eef3f0;
width: 95%;
margin-left: 2.5%;
}
.section1 {
display: flex;
justify-content: space-around;
margin-top: 5em;
}
<div class="body">
<div class="top-border"></div>
<div class="section1">
<div class="what-i-do">
<img class="what-i-do-icon" src="images/what-i-do.png" />
<h1 class="what-i-do-title">What I Do</h1>
<p class="what-i-do-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu,
a consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
<p class="view-more-btn">View More</p>
</div>
<div class="development">
<img class="development-icon" src="images/development.png" />
<h1 class="development-title">Development</h1>
<p class="development-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu,
a consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
</div>
<div class="design">
<img class="design-icon" src="images/design.png" />
<h1 class="design-title">Design</h1>
<p class="design-desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper quam arcu, a
consequat tellus cursus vel. Vivamus lacus massa, feugiat non malesuada sed, efficitur eu elit. </p>
</div>
</div>
</div>