I am trying to make a list with perfect alignment.
I have entered three items in the list but my list of with grey back ground is not appearing as same alignment as in the below picture.
My box width is changing according to the size of the font. I am providing both image in perfect same alignment and my image with two list item with not same width of grey background.
Below is the my css code:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 22px;
}
body {
min-height: 100vh;
font-family: 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.App {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
max-width: 500px;
border: 1px solid mediumblue;
margin: auto;
}
header {
width: 100%;
padding: 0 0.25em;
background-color: mediumblue;
color: aliceblue;
display: flex;
justify-content: space-between;
align-items: center;
}
main {
width: 100%;
display: flex;
flex-direction: column;
flex-grow: 1;
justify-content: center;
align-items: center;
overflow-y: auto;
}
footer {
width: 100%;
padding: 0.25em;
background-color: mediumblue;
color: aliceblue;
display: grid;
place-content: center;
}
ul {
width: 100%;
list-style: none;
padding: 0 0.25rem 0.25rem;
}
ul li::before {
content: "\200B";
}
.item {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 0.5rem 0 0.5rem 0.5rem;
margin: 0.25rem 0;
background-color: #eee;
}
.item: first-child {
margin: 0;
}
.item input[type="checkbox"] {
text-align: center;
width: 2.5rem;
width: 48px;
min-width: 48px;
height: 2.5rem;
height: 48px;
min-height: 48px;
cursor: pointer;
margin-right: 0.5rem;
}
.item input[type="checkbox"]:focus + label {
text-decoration: underline;
}
.item > label {
font-size: 0.75rem;
flex-grow: 1;
}
.item svg {
width: 48px;
min-width: 48px;
height: 36px;
font-size: 1rem;
color: steelblue;
cursor: pointer;
}
.item svg:focus,
.item svg:hover {
color: red;
outline: none;
}
Please guide me where I am doing mistake and why my grey background boxes are not same width as the below image.
Related
/* GLOBAL STYLES */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1{
Font-Family: 'Ovo', Serif;
font-size: 90px;
}
h2,h3,h4,h5,h6,p{
Font-Family: 'Quattrocento Sans', Sans-Serif;
}
:root{
--bg1: #E8E0D2;
--bg2: #9B9FAE;
--green: #5F6D45;
--font: #F5F1F1;
}
body{
width: 1920px;
max-width: 1920px;
background-color: var(--bg1);
}
.separator{
width: 80%;
margin: auto;
padding: 150px 0;
}
.line{
border-top: 1px solid var(--bg2);
}
html{
max-width: 1920px;
}
/* HEADER */
header{
width: 1920px;
height: 100px;
position: relative;
}
.header-container{
margin: auto;
width: 1520px;
height: inherit;
display: flex;
border-bottom: 1px solid black;
}
.header-container nav{
width: 50%;
height: inherit;
}
.logo{
position: relative;
bottom: 32px;
}
.nav-right{
display: flex;
justify-content: flex-end;
}
.nav-right ul{
width: 75%;
display: flex;
align-items: flex-end;
justify-content: space-between;
}
#nav-link{
display: flex;
display: inline-block;
}
#nav-link a{
float: right;
text-decoration: none;
color: black;
}
.nav-right h2{
font-size: 19px;
}
/* MAIN */
main{
display: flex;
flex-direction: column;
height: 800px;
width: 1920px;
margin: auto;
}
/* HERO */
.hero{
width: inherit;
height: inherit;
/* background-color: teal; */
}
.hero-container{
height: inherit;
display: flex;
justify-content: center;
}
#hero-half{
width: 100%;
/* border: 1px solid red; */
}
.hero-left{
display: flex;
justify-content: end;
}
.hero-left .container{
width: 79%;
height: 80%;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.name-intro h2{
color: var(--green);
font-size: 18px;
}
.name-intro h2{
}
.info-box{
position: relative;
top: 100px;
width: 50%;
background-color: var(--green);
padding: 15px;
border-radius: 3px;
box-shadow:-20px -10px var(--bg2);
}
.slogan{
color: white;
font-size: 20px;
letter-spacing: 1.1px;
line-height: 1.3;
text-align: center;
}
.hero-right{
display: flex;
justify-content: flex-end;
align-items: flex-end;
}
.img-container{
display: flex;
justify-content: center;
align-items: center;
background-color: var(--green);
width: 650px;
height: 650px;
border-radius: 3px;
background-image: url('./bg texture3.jpg');
background-blend-mode: multiply;
}
.me-img{
position: relative;
right: 75px;
width: 400px;
height: 560px;
}
.me-img img{
width: inherit;
height: inherit;
}
I Use a separator to add space and a horizontal line between the different sections of my webpage so they aren't touching, but whenever I either add margin or padding to the bottom of it the entire width of the page grows a tiny bit and now there's the sidescroll option. The extra width also appears when I add bottom margin directly to the sections themselves. Any help would be appreciated!
I've tried adding max-width to the page, but it still expands.
In your body and header, try changing width: 1920px; to max-width: 100%;. Also, in "hero-left", you may want to change that to "max-width" as well. In most cases, you wouldn't want to use width: 100%;
Currently the text headings which are inside a flexbox (the three divs) are not aligning with the main headings on the rest of the page.
See Image Here
The issue appears to only take place with the character length of the text headings inside the flexbox of three divs are not the same.
See Image of Alignment when character length is the same
I've unsuccessfully tried css alignments, but they do not appear to have an effect. My desired outcome for the three divs is something like this:
See successful reference alignment example
The code is here:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
max-width: 100vw;
list-style: none;
scroll-behavior: smooth;
}
body {
height: 100%;
margin: 0;
background-color: white;
font-family: Poppins;
min-height: 100vh;
}
a {
color: black;
}
/* ----------------------------------------------------------Landing Page -------------------------------------*/
.full-height-grow {
height: 100%;
display: flex;
flex-direction: column;
}
section {
display: flex;
height: 100vh;
width: auto;
max-width: 80vw;
min-width: 75vw;
justify-content: center;
align-items: center;
margin: 0 auto;
}
.about-container {
padding-top: 100px;
height: 100vh;
width: 90vw;
max-width: 90vw;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.about-img {
border-radius: 50%;
height: calc(80px + 40%);
width: auto;
}
.about-h1 {
font-family: 'Poppins', sans-serif;
color: rgb(255, 42, 95);
margin-top: 30px;
margin-right: -30px;
margin-left: -30px;
font-size:calc(12px + 0.8vw) ;
}
.about-h2 {
font-family: 'Poppins', sans-serif;
color: rgb(17, 17, 17);
margin-right: -30px;
margin-left: -30px;
font-size:calc(15px + 2vw) ;
font-weight: 500;
opacity: 0.9;
}
.about-desc {
font-family: Lora;
font-size:calc(10px + 1.2vw);
line-height: 1.8;
color: #888888;
text-align: center;
margin-left: 25vw;
margin-right: 25vw;
overflow:hidden;
z-index: 2;
width: auto;
}
.about-tasks-container {
align-self: center;
background-color: blanchedalmond;
max-width: 80vw;
width: 80vw;
display: flex;
justify-content: space-evenly;
text-align: center;
flex-direction: row;
flex-grow: 1;
}
.about-task-heading {
font-size: 80px;
}
.about-tasks-resources {
}
.about-tasks-learning {
}
<section class="about-section">
<div class="about-container" id="about">
<h2 class="about-h1"> ABOUT</h2>
<h3 class="about-h2">More About Me</h3>
<div class="about-tasks-container">
<div class="about-tasks-tutorials">
<h1 class="about-task-heading">Example</h1>
</div>
<div class="about-tasks-resources" >
<h1 class="about-task-heading">Exampler</h1>
</div>
<div class="about-tasks-learning">
<h1 class="about-task-heading">Examplers</h1>
</div>
</div>
</div>
</div>
</section>
(JSFiddle : https://jsfiddle.net/2cL5h4m6/9/)
Try this code
Idk if this is what you wanted but you can try it and you can see if it was the thing you looked for
* {
margin: 0;
padding: 0;
box-sizing: border-box;
max-width: 100vw;
list-style: none;
scroll-behavior: smooth;
}
body {
height: 100%;
margin: 0;
background-color: white;
font-family: Poppins;
min-height: 100vh;
}
a {
color: black;
}
/* ----------------------------------------------------------Landing Page -------------------------------------*/
.full-height-grow {
height: 100%;
display: flex;
flex-direction: column;
}
section {
display: flex;
height: 100vh;
width: auto;
max-width: 80vw;
min-width: 75vw;
justify-content: center;
align-items: center;
margin: 0 auto;
}
.about-container {
padding-top: 100px;
height: 100vh;
width: 90vw;
max-width: 90vw;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.about-img {
border-radius: 50%;
height: calc(80px + 40%);
width: auto;
}
.about-h1 {
font-family: 'Poppins', sans-serif;
color: rgb(255, 42, 95);
margin-top: 30px;
margin-right: -30px;
margin-left: -30px;
font-size:calc(12px + 0.8vw) ;
}
.about-h2 {
font-family: 'Poppins', sans-serif;
color: rgb(17, 17, 17);
margin-right: -30px;
margin-left: -30px;
font-size:calc(15px + 2vw) ;
font-weight: 500;
opacity: 0.9;
}
.about-desc {
font-family: Lora;
font-size:calc(10px + 1.2vw);
line-height: 1.8;
color: #888888;
text-align: center;
margin-left: 25vw;
margin-right: 25vw;
overflow:hidden;
z-index: 2;
width: auto;
}
.about-tasks-container {
align-self: center;
background-color: blanchedalmond;
max-width: 100vw;
width: 100vw;
display: flex;
justify-content: space-evenly;
text-align: center;
flex-direction: row;
flex-grow: 0;
}
.about-task-heading {
font-size: 30px;
}
.about-tasks-resources {
}
.about-tasks-learning {
}```
I am currently creating a bit of a fun project. For some reason, my text and check / radio boxes do not align with the text. They seem to be off to one side and higher than the text.
Here is my pen - https://codepen.io/Amnesia180/pen/RwKQOKP
html,
body {
line-height: 1.5;
height: 100%;
margin: 0 auto;
font-family: 'Quicksand', sans-serif;
color: #070707;
}
header {
position: relative;
top: 0;
padding: 0;
background-color: #EFEFEF;
width: 100%;
height: 60px;
}
.material-icons {
color: #505050;
}
#nav-bar {
position: relative;
display: flex;
justify-content: space-between;
padding: 10px;
}
ul {
display: flex;
padding: 0;
list-style: none;
}
li {
padding: 0px 20px;
}
.nav-link-left {
float: left;
text-decoration: none;
color: #070707;
font-weight: 800;
}
.nav-link {
float: right;
text-decoration: none;
color: #070707;
font-weight: 800;
}
.nav-link:hover {
float: right;
color: #5873D9;
border-bottom: 3px solid #5873D9;
padding-bottom: 5px;
}
#intro {
display: flex;
flex-direction: column;
align-items: center;
height: 470px;
margin-top: 50px;
max-width: 90em;
}
h1 {
font-size: 4em;
color: #34D1BF;
}
h2 {
color: #5873D9;
margin-top: 20px;
}
form {
display: flex;
flex-direction: column;
}
label {
font-size: 1.5em;
padding: 10px 0;
}
input {
width: 100%;
height: 30px;
border: 2px solid #34D1BF;
padding: 5px;
}
#submit {
background-color: #34D1BF;
width: 40%;
height: 40px;
margin-top: 15px;
margin-left: 30%;
margin-right: 30%;
border: 2px solid #34D1BF;
color: white;
}
#about,
#promo-image,
#burger {
max-width: 50em;
width: 90vw;
margin: 0 auto;
padding: 5px;
text-align: left;
}
#promoimage {
display: block;
margin: 0 auto;
max-width: 518px;
width: 100%;
}
#burgers {
margin-top: 40px;
flex-direction: column;
align-items: center;
text-align: center;
justify-content: space-around;
}
.box {
border: 2px solid #EFEFEF;
border-radius: 5px;
margin: 2px;
text-align: center;
}
.price {
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
}
.price li {
padding: 30px;
border: 0.5px solid #EFEFEF;
}
.card-header {
background-color: rgba(52, 209, 191, 1);
color: white;
}
footer {
width: 100%;
background-color: #EFEFEF;
height: 80px;
text-align: center;
}
footer p {
padding-top: 20px;
}
.burgerform {
text-align: left;
display: inline;
}
.burgerform label {
font-size: 1.5em;
font-weight: bold;
}
.burgerform legend {
font-weight: bold;
}
#media (min-width: 600px) {
#intro {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-evenly;
}
#burgers {
display: flex;
flex-direction: row;
align-items: center;
text-align: center;
justify-content: space-between;
}
}
<label>Sauces</label>
<p/> Burger Sauce <input type="checkbox" id="burgersauce" name="burgersauce" onclick="calculateTotal()"> Dirty Mayo Sauce
Can anyone advise?
Thanks!
Your inputs have width: 100%; which means it'll occupy entire width. And the "label" is just plain text so they are just flowing into the next line.
If you want to align them then you need proper elements (label>) aligned within 100% of the same line.
That is because you have given your inputs a width of 100%, so now each checkbox and radiobutton spans the whole width of the screen.
input {
width: 100%;
height: 30px;
border: 2px solid #34D1BF;
padding: 5px;
}
You can debug CSS issues using the CSS developer tools of your browser, as in the attached screenshot
Wrap both label (eg. Burger Mayo Sauce) and checkbox within a Flex-box, apply 100% width to it, and justify-content:space-between.
.menu-item{
witdh: 100%;
display:flex;
justify-content:space-between;
}
input[type=checkbox]{
//Whatever styling you want to apply to the checkbox.
}
Do not add the 100% width to the input, flexbox will manage the space for you.
Helo guys, im getting a weird white space on a border box. I have already try apply the next examples:
.blogPost1 {
grid-column: 1/3;
display: flex;
flex-flow: column;
border-radius: 0.4em;
border: 1px solid #595959;
}
img {
display: block;
padding: 0%;
margin: 0%;
width: 100%;
}
<div class="blogPost1">
<img src="https://via.placeholder.com/150.jpg" alt="">
<h1>Lorem consetetur sadipscing elitr.</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et</p>
</div>
Result:
fully css rules
html{
font-family: 'Poppins', sans-serif;
font-size: 17px;
}
* {
padding: 0;
margin: 0;
}
*, *::before, *::after {
box-sizing: border-box;
}
ul{
list-style: none;
}
body{
margin:0;
}
/* NavBar */
.navbar{
display: flex;
position: absolute;
align-items: center;
justify-content: center;
width: 100%;
flex-wrap: wrap;
color: #595959;
font-weight: 500;
font-size: 0.9em;
}
.firstLogo{
position: relative;
right: 15em;
}
.midleNav1{
position: relative;
display: flex;
align-items: center;
right: 1.6em;
}
.midleNav1 a{
padding: 1em;
text-transform: uppercase;
}
.socialIcons{
position: relative;
left: 15em;
}
.socialIcons a{
padding: 0.1em;
}
/* Hero Section */
.container{
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100vh;
}
.container::before{
content:"";
background-image: url(/images/heroImg.png);
background-size: cover;
position: absolute;
top: 9em;
right: 0px;
bottom: 0px;
left: 0px;
width: 100%;
max-height: 512px;
opacity: 17%;
}
.hero{
position: relative;
display: flex;
flex-wrap: wrap;
/*width: 100%;*/
align-items: center;
justify-content: center;
}
.hero h1{
position: relative;
color: #595959;
width: 13em;
font-size: 2.4em;
left: 1em;
}
.hero h6{
color: #595959;
opacity: 70%;
position: relative;
left: 8.8em;
bottom: 3em;
padding-bottom: 1em;
font-size: 0.7em;
}
.hero button{
position: relative;
font-weight: 600;
right: 2.5em;
padding: 1em 2em;
text-align: center;
background-color: #E76F51;
border: none;
border-radius: 0.3em;
color: white;
font-size: 1em;
box-shadow: 2px 3px 6px rgba(0, 0, 0, 0.479) ;
}
/* GRID SECTION*/
.grid{
position: relative;
bottom: 5em;
display: grid;
grid-template-columns: 50% 50%;
grid-template-rows: 1fr 1fr;
grid-template-areas:
"first second"
"third fourth"
;
}
.first{
display: flex;
flex-wrap: wrap;
grid-area: first;
background-color: #E76F51;
padding: 4em;
align-items: center;
justify-content: center;
}
.first svg{
position: relative;
left: 0.5em;
top: 0.6em;
}
.second{
display: flex;
flex-flow: column;
grid-area: second;
background-color: white;
align-items: center;
justify-content: center;
text-align: center;
color: #595959;
}
.second svg{
width: 5em;
padding-bottom: 1em;
}
.second h1{
padding-bottom: 1em;
font-size: 1.8em;
font-weight: 600;
}
.second h3{
font-size: 1.5em;
width: 18em;
font-weight: 400;
line-height: 1.5em;
}
.third{
display: flex;
flex-flow: column;
grid-area: third;
background-color: white;
align-items: center;
justify-content: center;
text-align: center;
color: #595959;
}
.third svg{
width: 5em;
padding-bottom: 1em;
}
.third h1{
padding-bottom: 1em;
font-size: 1.8em;
font-weight: 600;
}
.third h3{
width: 20em;
font-size: 1.5em;
font-weight: 400;
line-height: 1.5em;
}
.fourth{
display: flex;
flex-wrap: wrap;
grid-area: fourth;
background-color: #2A9D8F;
padding: 4em;
align-items: center;
justify-content: center;
}
.fourth svg{
position: relative;
left: 0.5em;
top: 0.6em;
}
/* Sentence */
.sentence{
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
opacity: 60%;
}
/* BLOG POST */
.blogTitle{
position: relative;
padding-left: 2.5em;
}
.blogBox{
position: relative;
display: grid;
justify-content: center;
grid-template-columns: repeat(4, minmax(12em ,25%));
grid-template-rows: auto;
gap: 1em;
padding: 0 5em 0 5em;
}
.blogPost1{
grid-column: 1/3;
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
/* outline: 1px solid #595959; */
}
.blogPost2{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogPost3{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogPost4{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogPost5{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogPost6{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogPost7{
/* display: flex;
flex-flow: column; */
border-radius: 0.4em;
border: 1px solid #595959;
}
.blogBox h1{
font-size: 1.2rem;
padding: 0.5em;
}
.blogBox p{
font-size: 0.9rem;
padding: 0.5em;
}
img{
margin: 0px;
padding: 0px;
width: 100%;
height: auto;
display: block;
}
the snippet have white space if you did not saw, maybe your lcd have bad resolution.
you could try the css:
box-sizing: border-box;
maybe it has an effect for your case
I have a section in which is displaying via a flex box. This works great, but when the viewport gets to a 640px or less size, I want to be able to make all three section be shown in a display: block fashion with a width of 100%. I tried changing the #contact-section to display: block, but it went completely out of the format I have with flex.
I am wanting it to appear like this under 640px's.
Does anyone know how I can do it without losing the flex format, or at least making it work in this viewport?
Here is a fiddle which will allow the sections to be seen in a 640 or less viewport.
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width:640px) {
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 1px;
height: 3em;
order: 2;
display: block;
width: 100%;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us</div>
</div>
I have changed the direction to column, seems that now it works
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width: 640px) {
#contact-section {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 10px;
order: 2;
display: block;
width: 100%;
background-color: red;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
text-align: center;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
You could use min-width instead mediaqueries and flex-wrap:wrap and eventually border(s) on the first element to drop the pseudo ::before. See Fiddle test 1 & Fiddle test 2 .
#contact-section {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
}
#contact-section:before {} #contact-section-left {
font-size: 1.5em;
font-style: italic;
min-width: 320px;
border-top: 1em solid transparent;
border-bottom: 1em solid transparent;
border-right: 1px solid white;
padding: 1em;
flex: 1;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
padding: 1em;
flex: 1;
min-width: 320px;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
edit
if you still want to use a pseudo of 3em height, then you can draw it from the first box https://jsfiddle.net/mq41hgkp/3/