Problem when displaying articles inline block [duplicate] - html

This question already has answers here:
Align inline-block DIVs to top of container element
(5 answers)
Closed 1 year ago.
I'm trying to learn HTML and CSS. However, I was doing an exercise, and now I'm stuck because those 4 articles in <section id="news"> don't display side by side, and I wasn't able to figure out what was happening.
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #1A4575;
}
header {
background-color: #2F5075;
width: 600px;
text-align: center;
margin: 10px;
}
nav {
display: inline-block;
}
nav>a {
text-decoration: none;
background-color: #2B71C2;
color: white;
}
nav>a:hover {
color: #80B7F7;
}
header>h1 {
display: inline-block;
}
section#breaking>article {
width: 700px;
background-color: rgba(172, 35, 35, 0.719);
color: white;
font-size: 20px;
margin: 5px;
padding: 3.5px;
}
section#news {
background-color: #2B88C2;
}
section#news>article {
width: 400px;
height: 250px;
display: inline-block;
background-color: white;
color: black;
border: 3px solid black;
margin: 5px 5px 5px 5px;
padding: 5px 5px;
}
section#news>h1 {
text-align: center;
padding: 5px;
}
aside {
background-color: #1A4575;
color: white;
}
footer {
background-color: #2F5075;
text-align: center;
color: #368FF5;
}
<header>
<h1>Menu</h1>
<nav>
a
b
c
d
e
</nav>
</header>
<main>
<section id="breaking">
<article>
<h2>Breaking news</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Assumenda culpa asperiores voluptate. Eius pariatur vero, at repellendus sunt sequi ad qui doloribus excepturi provident ipsam, libero deleniti culpa nihil et.</p>
<aside>
<p>Written by João Marcelo</p>
</aside>
</article>
</section>
<section id="news">
<h1>Daily News</h1>
<article>
<h2>Title 1</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Impedit amet facilis officia ex eos quae possimus nisi, nostrum saepe, debitis obcaecati ea doloribus adipisci, soluta veritatis! Deserunt quam molestias ut.
</p>
<aside>
<p>Written by Pedro Henrique Vasconcelos</p>
</aside>
</article>
<article>
<h2>Title 2</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Leonardo Alves de Paiva</p>
</aside>
</article>
<article>
<h2>Title 3</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Beatriz halfd</p>
</aside>
</article>
<article>
<h2>Title 4</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Joana Bohemia</p>
</aside>
</article>
</section>
</main>
<footer>
<p>Developed by Leonardo</p>
</footer>

Set the vertical align to top on the articles. The default is baseline.
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #1A4575;
}
header {
background-color: #2F5075;
width: 600px;
text-align: center;
margin: 10px;
}
nav {
display: inline-block;
}
nav>a {
text-decoration: none;
background-color: #2B71C2;
color: white;
}
nav>a:hover {
color: #80B7F7;
}
header>h1 {
display: inline-block;
}
section#breaking>article {
width: 700px;
background-color: rgba(172, 35, 35, 0.719);
color: white;
font-size: 20px;
margin: 5px;
padding: 3.5px;
}
section#news {
background-color: #2B88C2;
}
section#news>article {
width: 400px;
height: 250px;
display: inline-block;
background-color: white;
color: black;
border: 3px solid black;
margin: 5px 5px 5px 5px;
padding: 5px 5px;
vertical-align:top;
}
section#news>h1 {
text-align: center;
padding: 5px;
}
aside {
background-color: #1A4575;
color: white;
}
footer {
background-color: #2F5075;
text-align: center;
color: #368FF5;
}
<header>
<h1>Menu</h1>
<nav>
a
b
c
d
e
</nav>
</header>
<main>
<section id="breaking">
<article>
<h2>Breaking news</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Assumenda culpa asperiores voluptate. Eius pariatur vero, at repellendus sunt sequi ad qui doloribus excepturi provident ipsam, libero deleniti culpa nihil et.</p>
<aside>
<p>Written by João Marcelo</p>
</aside>
</article>
</section>
<section id="news">
<h1>Daily News</h1>
<article>
<h2>Title 1</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Impedit amet facilis officia ex eos quae possimus nisi, nostrum saepe, debitis obcaecati ea doloribus adipisci, soluta veritatis! Deserunt quam molestias ut.
</p>
<aside>
<p>Written by Pedro Henrique Vasconcelos</p>
</aside>
</article>
<article>
<h2>Title 2</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Leonardo Alves de Paiva</p>
</aside>
</article>
<article>
<h2>Title 3</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Beatriz halfd</p>
</aside>
</article>
<article>
<h2>Title 4</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi asperiores quo omnis fugit error ipsum provident aut libero consequatur minima illo, distinctio sed, culpa temporibus deserunt obcaecati quidem. Quia, assumenda.
</p>
<aside>
<p>Written by Joana Bohemia</p>
</aside>
</article>
</section>
</main>
<footer>
<p>Developed by Leonardo</p>
</footer>

Related

align divs side by side

I want to align divs side by side but the padding doesn't let the divs to align side by side and I'm not allowed to remove padding or change anything. just need to add a property and i don't know what property I should add.
Here's the code:
body {
padding: 30px;
}
section {
background: lightgreen;
width: 75%;
float: left;
}
article {
background: white;
margin: 0 0 1rem 0;
}
aside {
background: pink;
width: 25%;
float: right;
}
header,
article,
section,
.module {
padding: 1rem;
}
<section>
<article>
<h2>Title</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo
molestias ex officia eligendi reiciendis fuga magnam? Ullam ut ab
doloremque accusamus iusto aliquam facilis sapiente!
</p>
</article>
<article>
<h2>Title</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo
molestias ex officia eligendi reiciendis fuga magnam? Ullam ut ab
doloremque accusamus iusto aliquam facilis sapiente!
</p>
</article>
</section>
<aside>
<div className="module">
<h3>Module</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio rem
ab delectus fugit repellendus perspiciatis dolor consequuntur
tenetur voluptatem a vitae odit aspernatur? Voluptas quisquam
corporis nostrum aspernatur aliquid harum saepe ab pariatur veniam
iste ipsam alias nemo voluptatibus doloribus.
</p>
</div>
</aside>
box-sizing CSS will fix this issue.
Add default box-sizing property to border-box
* {
box-sizing: border-box;
}

How do I expand a flex box to the left and right with css?

So I'm setting up a baseline for a portfolio for this project and I want the projects on the home page so when I hover over them they expand a bit. Everything is working fine except I want the boxes' height and width to expand evenly on all sides. The boxes seem to be expanding toward the center when I hover over them.
main {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.project {
width: 200px;
height: 200px;
border: 15px solid rgb(2, 2, 59);
padding: 50px;
margin: 20px;
text-align: center;
}
.project:hover {
width: 250px;
height: 250px
}
#proj1 {
background-image: url("https://images.unsplash.com/photo-1587145820266-a5951ee6f620?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Y2FsY3VsYXRvcnxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&w=1000&q=80");
background-size: cover;
background-position: center;
}
h2 {
padding: 3%;
}
<main>
<section>
<section class="project" id="proj1">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Placeat veniam alias, beatae, eos quidem nostrum tempore provident molestiae officia qui vero at sed consectetur reprehenderit repellat hic omnis aliquam! Saepe!</p1>
</section>
<section class="project" id="proj2">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Id doloribus possimus quod excepturi perferendis! Eius illo, officia nihil culpa natus maiores totam dolorem animi facilis, quae reiciendis in blanditiis quam!</p1>
</section>
</section>
<section>
<section class="project" id="proj3">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
<section class="project" id="proj4">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
</section>
</main>
If you use transform: scale(1.2); instead, then your objects will keep their position and size in the document flow. Here is an example:
main {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.project {
width: 200px;
border: 15px solid rgb(2, 2, 59);
padding: 40px;
margin: 40px;
text-align: center;
transition: transform .5s;
}
.project:hover {
transform: scale(1.2);
}
#proj1 {
background-image: url("https://images.unsplash.com/photo-1587145820266-a5951ee6f620?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Y2FsY3VsYXRvcnxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&w=1000&q=80");
background-size: cover;
background-position: center;
}
h2 {
padding: 3%;
}
<main>
<section>
<section class="project" id="proj1">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Placeat veniam alias, beatae, eos quidem nostrum tempore provident molestiae officia qui vero at sed consectetur reprehenderit repellat hic omnis aliquam! Saepe!</p1>
</section>
<section class="project" id="proj2">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Id doloribus possimus quod excepturi perferendis! Eius illo, officia nihil culpa natus maiores totam dolorem animi facilis, quae reiciendis in blanditiis quam!</p1>
</section>
</section>
<section>
<section class="project" id="proj3">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
<section class="project" id="proj4">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
</section>
</main>
You should probably be using scale transforms instead of pixel sizing. You can then specify the transform origin.
main {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.project {
width: 200px;
height: 200px;
border: 15px solid rgb(2, 2, 59);
padding: 50px;
margin: 20px;
text-align: center;
transition: all 0.3s;
}
.project:hover {
transform: scale(1.05);
}
#proj1 {
background-image: url("https://images.unsplash.com/photo-1587145820266-a5951ee6f620?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Y2FsY3VsYXRvcnxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&w=1000&q=80");
background-size: cover;
background-position: center;
}
h2 {
padding: 3%;
}
<main>
<section>
<section class="project" id="proj1">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Placeat veniam alias, beatae, eos quidem nostrum tempore provident molestiae officia qui vero at sed consectetur reprehenderit repellat hic omnis aliquam! Saepe!</p1>
</section>
<section class="project" id="proj2">
<h2>Project Name</h2>
<p1>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Id doloribus possimus quod excepturi perferendis! Eius illo, officia nihil culpa natus maiores totam dolorem animi facilis, quae reiciendis in blanditiis quam!</p1>
</section>
</section>
<section>
<section class="project" id="proj3">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
<section class="project" id="proj4">
<h2>Project Name</h2>
<p1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ad deleniti labore ea, laborum placeat odit? Architecto qui quae ad atque iure impedit reiciendis ab inventore, modi asperiores aspernatur porro officiis.</p1>
</section>
</section>
</main>

Image won't center inside Article and Aside for some reason

I am trying to center images inside my <article> and <aside>, and i am not sure what's wrong with the code. I tried to make some adjustments using article#tablet but no success. Now the images lays on the left, no matter what...if i inspect the item and give it a margin or padding it will react. But can not center it.
.inner-wrapper {
float: left;
width: 100%;
background-color: #C3D7DF;
}
article {
float: left;
margin: 0 auto;
width: 50%;
height: auto;
}
#tablet {
background-color: #C3D7DF;
}
aside {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
}
#tablet2 {
background-color: #A2B2C1;
}
#mobile {
background-color: #BEB9AD;
}
#desktop {
background-color: #F1AA90;
}
.inner-wrapper-2 {
float: left;
width: 100%;
background-color: #C3D7DF;
}
<section class="inner-wrapper">
<article id="tablet">
<img src="https://via.placeholder.com/150x150" alt="">
</article>
<aside id="tablet2">
<h2>MOBILE. TABLET. DESKTOP.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum a, commodi dolor fugit deleniti ipsam eveniet exercitationem, repudiandae, tempore aspernatur eum id delectus placeat ullam possimus quis sequi cupiditate amet?</p>
</aside>
</section>
<section class="inner-wrapper-2">
<article id="mobile">
<h2>ACROSS EACH DEVICE</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt error animi nobis reiciendis quaerat sint itaque dicta, aut vel molestias? Ipsam non expedita incidunt ea cupiditate voluptas fuga magnam.</p>
</article>
<aside>
<img src="https://via.placeholder.com/150x150" alt="">
</aside>
</section>
<section class="inner-wrapper">
<article>
<img src="https://via.placeholder.com/150x150" alt="">
</article>
<aside id="desktop">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo a quasi vero consequuntur aut atque, incidunt dolor eos quas numquam debitis architecto dolore delectus aspernatur, et amet sequi vel maxime.</p>
</aside>
</section>
Any help i would appreciate. Thank you
You can make use of flexbox in this situation. According to your need, just use the align-items and justify-content properly.
.inner-wrapper {
float: left;
width: 100%;
background-color: #C3D7DF;
display: flex;
align-items: center;
}
article {
float: left;
margin: 0 auto;
width: 50%;
height: auto;
}
.img-wrapper img {
width: 50px;
height: 50px;
}
.img-wrapper {
display: inline-flex;
align-items: center; /**Vertical */
justify-content: center; /**Horizontal */
height: 100%;
flex: 1;
}
#tablet {
background-color: #C3D7DF;
}
aside {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
}
#tablet2 {
background-color: #A2B2C1;
}
#mobile {
background-color: #BEB9AD;
}
#desktop {
background-color: #F1AA90;
}
.inner-wrapper-2 {
float: left;
width: 100%;
background-color: #C3D7DF;
}
<section class="inner-wrapper">
<article id="tablet" class='img-wrapper'>
<img src="https://4.img-dpreview.com/files/p/E~TS590x0~articles/3925134721/0266554465.jpeg" alt="">
</article>
<aside id="tablet2">
<h2>MOBILE. TABLET. DESKTOP.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum a, commodi dolor fugit deleniti ipsam eveniet exercitationem, repudiandae, tempore aspernatur eum id delectus placeat ullam possimus quis sequi cupiditate amet?</p>
</aside>
</section>
<section class="inner-wrapper">
<article id="mobile">
<h2>ACROSS EACH DEVICE</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt error animi nobis reiciendis quaerat sint itaque dicta, aut vel molestias? Ipsam non expedita incidunt ea cupiditate voluptas fuga magnam.</p>
</article>
<aside class='img-wrapper'>
<img src="https://4.img-dpreview.com/files/p/E~TS590x0~articles/3925134721/0266554465.jpeg" alt="">
</aside>
</section>
<section class="inner-wrapper">
<article class='img-wrapper'>
<img src="https://4.img-dpreview.com/files/p/E~TS590x0~articles/3925134721/0266554465.jpeg" alt="">
</article>
<aside id="desktop">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo a quasi vero consequuntur aut atque, incidunt dolor eos quas numquam debitis architecto dolore delectus aspernatur, et amet sequi vel maxime.</p>
</aside>
</section>
Your CSS does not have any styles for images.
To center the image in your you have to select it and apply styles to it, for example an auto margin and display: block:
.inner-wrapper {
float: left;
width: 100%;
background-color: #C3D7DF;
}
article {
float: left;
margin: 0 auto;
width: 50%;
height: auto;
}
#tablet {
background-color: #C3D7DF;
}
aside {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
}
/* Added this */
article img,
aside img {
display: block;
margin: 0 auto;
}
#tablet2 {
background-color: #A2B2C1;
}
#mobile {
background-color: #BEB9AD;
}
#desktop {
background-color: #F1AA90;
}
.inner-wrapper-2 {
float: left;
width: 100%;
background-color: #C3D7DF;
}
<section class="inner-wrapper">
<article id="tablet">
<img src="./img/hand_ipad.png" alt="">
</article>
<aside id="tablet2">
<h2>MOBILE. TABLET. DESKTOP.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum a, commodi dolor fugit deleniti ipsam eveniet exercitationem, repudiandae, tempore aspernatur eum id delectus placeat ullam possimus quis sequi cupiditate amet?</p>
</aside>
</section>
<section class="inner-wrapper-2">
<article id="mobile">
<h2>ACROSS EACH DEVICE</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt error animi nobis reiciendis quaerat sint itaque dicta, aut vel molestias? Ipsam non expedita incidunt ea cupiditate voluptas fuga magnam.</p>
</article>
<aside>
<img src="https://picsum.photos/200/300" alt="">
</aside>
</section>
<section class="inner-wrapper">
<article>
<img src="https://picsum.photos/300/300" alt="">
</article>
<aside id="desktop">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo a quasi vero consequuntur aut atque, incidunt dolor eos quas numquam debitis architecto dolore delectus aspernatur, et amet sequi vel maxime.</p>
</aside>
</section>
You want to center the image inside the <aside> and <article> right ?
Just add property : text-align : center in the aside and article, the images inside them will be centered.
Checkout in codepen for more detail
https://codepen.io/anon/pen/PddMYZ
Or only necessary code here (The css file) :
.inner-wrapper {
float: left;
width: 100%;
background-color: #C3D7DF;
}
article {
float: left;
margin: 0 auto;
width: 50%;
height: auto;
text-align : center;
}
#tablet {
background-color: #C3D7DF;
}
aside {
float: right;
margin: 0 auto;
width: 50%;
height: auto;
}
#tablet2 {
background-color: #A2B2C1;
}
#mobile {
background-color: #BEB9AD;
}
#desktop {
background-color: #F1AA90;
}
.inner-wrapper-2 {
float: left;
width: 100%;
background-color: #C3D7DF;
}
aside{
text-align : center;
}
This is another simple method.
I have wrapped image in a div and added single css line for that div.
section {
float: left;
width: 100%;
background-color: #C3D7DF;
}
article {
float: left;
width: 50%;
background-color: #A2B2C1;
}
aside {
float: right;
width: 50%;
background-color: #C3D7DF;
}
/*css which I have added*/
.img-wrapper {
text-align: center;
}
<section>
<article>
<h2>Article Block.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum a, commodi dolor fugit deleniti ipsam eveniet exercitationem, repudiandae, tempore aspernatur eum id delectus placeat ullam possimus quis sequi cupiditate amet?</p>
<div class="img-wrapper">
<img src="https://via.placeholder.com/150x150" alt="">
</div>
</article>
<aside>
<h2>Aside Block.</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum a, commodi dolor fugit deleniti ipsam eveniet exercitationem, repudiandae, tempore aspernatur eum id delectus placeat ullam possimus quis sequi cupiditate amet?</p>
<div class="img-wrapper">
<img src="https://via.placeholder.com/150x150" alt="">
</div>
</aside>
</section>

How to eliminate the margin of div boxes

I created a few div and gave some colours to it in order to see the difference on changes as I code and see that there is a big white spacing between each box.
How can I remove these white spaces?
Here my fiddle: https://jsfiddle.net/Wosley_Alarico/8tgLzjeq/
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="content">
<ul>
<li><a id="deposit" href="#">Deposit</a></li>
<li><a id="account" href="#">Account</a></li>
<li><a id="credit" href="#">Credit</a></li>
</ul>
<div class="box deposit">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio sunt voluptates reprehenderit similique nostrum eius repudiandae odio eos obcaecati doloremque quam quos, officiis veritatis blanditiis soluta molestiae iusto illo corrupti.</p>
</div>
<div class="box account">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio sunt voluptates reprehenderit similique nostrum eius repudiandae odio eos obcaecati doloremque quam quos, officiis veritatis blanditiis soluta molestiae iusto illo corrupti.</p>
</div>
<div class="box credit">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio sunt voluptates reprehenderit similique nostrum eius repudiandae odio eos obcaecati doloremque quam quos, officiis veritatis blanditiis soluta molestiae iusto illo corrupti.</p>
</div>
</div>
<div id="random">
<p>This is a random text</p>
</div>
CSS:
li{
list-style:none;
color: white;
width: 30%;
a{
color: white;
text-decoration: none;
&:hover{
color: blue;
}
}
}
ul{
background: black;
padding: 20px 0;
text-align: center;
display: flex;
justify-content: center;
}
.box{
height: 200px;
}
.deposit{
background-color: green;
}
.account{
background: pink;
}
.credit{
background: blue;
}
li a.active{
color: red;
}
Hope you can help
remove the p margins and replace them with paddings if needed: p{margin:0;}

Where is the sidebar in this pen?

How can you fix sidebar issue here:
http://codepen.io/chriscoyier/pen/ClGcF
body {
padding: 30px;
}
header {
background: lightblue;
}
section {
background: lightgreen;
width: 75%;
float: left;
}
article {
background: white;
margin: 0 0 1rem 0;
}
aside {
background: pink;
width: 25%;
float: right;
}
header,
article,
section,
.module {
padding: 1rem;
}
<main>
<header>
<h1>Site</h1>
</header>
<section>
<article>
<h2>Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo molestias ex officia eligendi reiciendis fuga magnam? Ullam ut ab doloremque accusamus iusto aliquam facilis sapiente!</p>
</article>
<article>
<h2>Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo molestias ex officia eligendi reiciendis fuga magnam? Ullam ut ab doloremque accusamus iusto aliquam facilis sapiente!</p>
</article>
</section>
<aside>
<div class="module">
<h3>Module</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio rem ab delectus fugit repellendus perspiciatis dolor consequuntur tenetur voluptatem a vitae odit aspernatur? Voluptas quisquam corporis nostrum aspernatur aliquid harum saepe ab pariatur
veniam iste ipsam alias nemo voluptatibus doloribus.</p>
</div>
</aside>
</main>
The goal is to have the sidebar move back to the top.
My confusion:
Where is the sidebar there inside the pen?
<aside> is the sidebar part.
In your css:
*,*:after,*:before { box-sizing: border-box; }
You can read about box-sizing following this link: http://www.paulirish.com/2012/box-sizing-border-box-ftw/
The problem is that you are telling the program to take up 100% of the pagewidth. If you reduce the two widths to 70% and 20-25%, the sidebar will float right, adjacent to the main content body.