The body is flexbox ,I do not how to display the divs in top-right corner and bottom-left corner?
body {
box-sizing: border-box;
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #f5f7fb;
color: #122763;
}
main {
display: flex;
flex-direction: column;
align-items: center;
}
*,
*::before,
*::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #f5f7fb;
color: #122763;
}
/**top Right**/
main {
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
top: 0;
right: 0;
}
/**Bottom Left**/
main {
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
bottom: 0;
left: 0;
}
/**No Need to set body position to relative**/
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
main {
height: 100vh;
width: 100%;
background-color: #f5f7fb;
color: #122763;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
overflow: hidden;
}
main::before {
content: '';
height: 40vh;
width: 20%;
margin-right: -9vw;
margin-top: -18vh;
align-self: flex-end;
background-color: #fffad2;
border-radius: 44%;
}
main::after {
content: '';
height: 40vh;
width: 25%;
margin-left: -14vw;
margin-bottom: -18vh;
align-self: flex-end;
align-self: flex-start;
background-color: #deecf9;
border-radius: 50%;
}
.container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.container > h1 {
margin: 1%;
}
.container > p {
margin: 0.5% 1% 1% 1%;
font-size: large;
}
.container > button {
font-size: medium;
color: white;
background-color: #4d5b9e;
border-radius: 1rem;
width: 95px;
height: 45px;
border: 0;
margin: 2%;
cursor: pointer;
}
Related
The fourth block's red cards (the block on middle right of the image) will not respond to look like this image in figma.
They currently look like this on my live server from VScode.
Here is my HTML.
Below is my latest effort in CSS.
I have been trying to fix this since last Wednesday.
I'm completely new to this field and this is my first class (front end web dev).
What am I fundamentally misunderstanding here?
.parent {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 1152px;
margin: auto;
background-color: #370617;
}
.container {
background-color: #F48C06;
border: none;
border-radius: 8px;
width: 468px;
height: 160px;
position: relative;
margin: 20px;
display: flex;
}
.card {
background-color:#9D0208;
border: none;
border-radius: 4px;
width: 78px;
height: 78px;
margin: 15px;
display: flex;
justify-content: center;
align-items: center;
}
.first-block {
display: flex;
justify-content: flex-start;
align-items: flex-end;
width: 468px;
height: 160px;
margin: 20px
}
.second-block {
display: flex;
justify-content: center;
align-items: center;
width: 468px;
height: 160px;
margin: 20px;
}
.sb-cardone {
height: 120px;
}
.sb-cardtwo {
height: 120px;
}
.sb-cardthree {
height: 120px;
}
.third-block{
display: flex;
justify-content: flex-end;
align-items: center;
}
.fourth-block {
display: flex;
width: 468px;
height: 160px;
}
.fb-cardone {
display: flex;
justify-content: flex-start;
align-items: flex-start;
margin-top: 20px;
margin-left: 20px;
}
.fb-cardtwo {
display: flex;
justify-content: center;
align-self: center;
}
.fb-cardthree {
display: flex;
justify-content: flex-end;
align-self: flex-end;
}
body {
background-color: #370617;;
margin: 0;
min-height: 100vh;
}
I'm making web-site , and i need make adaptive site. So i began use media-quires and got a trouble. When screen resolution has been changing in example since 2560px to 1920px , some styles remain in site, however they hasn't written in code CSS, why ?
#media only screen and (max-width: 2560px ) {
body {
background-color: #344B56;
color: white;
font-family: Montserrat;
margin: 0px;
padding-top: 20px;
}
.container {
margin: 0 auto;
}
.info {
display: flex;
justify-content: space-around;
align-items: flex-start;
padding-bottom: 5px;
}
.company {
text-decoration: none;
color: white;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
font-size: 30px;
text-align: center;
}
.company p {
margin: 0px;
}
.hours, .adress, .callback {
display: flex;
align-items: flex-start;
}
.logo {
width: 50px;
padding-top: 12px;
padding-right: 10px;
}
.navbar {
display: flex;
justify-content: space-evenly;
padding: 20px;
border-top: 1px white solid;
border-radius: 50px;
}
.completed {
font-size: 20px;
font-family: Montserrat;
border-bottom: 2px skyblue solid;
border-radius: 5px;
margin: 0px;
padding: 0px;
}
.navbar a {
letter-spacing: -2px;
color: white;
font-size: 20px;
font-family: Montserrat;
text-decoration: none;
}
.navbar a:hover {
color: skyblue;
}
.company_info {
display: flex;
justify-content: space-around;
align-items: center;
background-color: #323a42;
}
.company_text {
display: flex;
flex-direction: column;
width: 500px;
padding: 50px;
}
.infoCompany {
background-image: url("./images/companyBack.jpeg");
background-position: center center;
background-size: cover;
width: 100%;
height: 600px;
}
.infoCompany__Text {
display: flex;
flex-direction: column;
color: white;
width: 100%;
font-size: 26px;
}
.infoCompany__Text_Company {
display: flex;
margin-top: 100px;
margin-left: 200px;
}
.Service {
margin-top: 50px;
margin-left: 200px;
margin-right: 200px;
color: white;
font-size: 24px;
}
.Service__Products {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
}
.Service__Products_Product {
display: flex;
flex-direction: column;
margin-top: 50px;
}
.Service__Products_Product:not(first-child) {
margin-left: 150px;
}
.Product__img {
width: 500px;
height: 402px;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.Product__DownPartCard {
display: flex;
}
.Product__LeftDivCard {
width: 24px;
height: 98px;
background-color: #1A81AD;
}
.Product__NameCardDiv {
width: 476px;
height: 98px;
background: white;
}
.Product__DownPartCard_Text {
font-size: 18px;
display: flex;
color: black;
padding-left: 15px;
padding-top: 30px;
}
.Garant {
color: white;
margin-top: 100px;
margin-left: 200px;
margin-right: 200px;
color: white;
font-size: 24px;
}
.Garant__Garants {
margin-top: 70px;
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.Garant__Card {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.Gatant__Card_Img {
width: 150px;
height: 150px;
}
.Gatant__Card_Text {
font-size: 16px;
}
footer {
margin-top: 70px;
position: absolute;
width: 100%;
border-top: 1px white solid;
}
.invisible {
opacity: 0;
}
}
#media only screen and (max-width: 1920px ) {
body {
background-color: #344B56;
color: white;
font-family: Montserrat;
margin: 0px;
padding-top: 20px;
}
.container {
margin: 0 auto;
}
.info {
display: flex;
justify-content: space-around;
align-items: flex-start;
padding-bottom: 5px;
}
.company {
text-decoration: none;
color: white;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
font-size: 30px;
text-align: center;
}
.company p {
margin: 0px;
}
.hours, .adress, .callback {
display: flex;
align-items: flex-start;
}
.logo {
width: 50px;
padding-top: 12px;
padding-right: 10px;
}
.navbar {
display: flex;
justify-content: space-evenly;
padding: 20px;
border-top: 1px white solid;
border-radius: 50px;
}
.completed {
font-size: 20px;
font-family: Montserrat;
border-bottom: 2px skyblue solid;
border-radius: 5px;
margin: 0px;
padding: 0px;
}
.navbar a {
letter-spacing: -2px;
color: white;
font-size: 20px;
font-family: Montserrat;
text-decoration: none;
}
.navbar a:hover {
color: skyblue;
}
.company_info {
display: flex;
justify-content: space-around;
align-items: center;
background-color: #323a42;
}
.company_text {
display: flex;
flex-direction: column;
width: 500px;
padding: 50px;
}
.infoCompany {
background-image: url("./images/companyBack.jpeg");
background-position: center center;
background-size: cover;
width: 100%;
height: 600px;
}
.infoCompany__Text {
display: flex;
flex-direction: column;
color: white;
width: 100%;
font-size: 26px;
}
.infoCompany__Text_Company {
display: flex;
margin-top: 100px;
margin-left: 200px;
}
.Service {
margin-top: 50px;
margin-left: 200px;
margin-right: 200px;
color: white;
font-size: 24px;
}
.Service__Products {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
}
.Service__Products_Product {
display: flex;
flex-direction: column;
margin-top: 50px;
}
.Product__img {
width: 400px;
height: 302px;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.Product__DownPartCard {
display: flex;
}
.Product__LeftDivCard {
width: 12px;
height: 98px;
background-color: #1A81AD;
}
.Product__NameCardDiv {
width: 388px;
height: 98px;
background: white;
}
.Product__DownPartCard_Text {
font-size: 15px;
display: flex;
color: black;
padding-left: 15px;
padding-top: 30px;
}
.Garant {
color: white;
margin-top: 100px;
margin-left: 200px;
margin-right: 200px;
color: white;
font-size: 24px;
}
.Garant__Garants {
margin-top: 70px;
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.Garant__Card {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.Gatant__Card_Img {
width: 150px;
height: 150px;
}
.Gatant__Card_Text {
font-size: 16px;
}
footer {
margin-top: 70px;
position: absolute;
width: 100%;
border-top: 1px white solid;
}
.invisible {
opacity: 0;
}
}
#media only screen and (max-width: 1500px) {
body {
background-color: #344B56;
color: white;
font-family: Montserrat;
margin: 0px;
padding-top: 20px;
}
.container {
margin: 0 auto;
}
.info {
display: flex;
justify-content: space-around;
align-items: flex-start;
padding-bottom: 5px;
}
.company {
text-decoration: none;
color: white;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
font-size: 30px;
text-align: center;
}
.company p {
margin: 0px;
}
.hours, .adress, .callback {
display: flex;
align-items: flex-start;
}
.logo {
width: 50px;
padding-top: 12px;
padding-right: 10px;
}
.navbar {
display: flex;
justify-content: space-evenly;
padding: 20px;
border-top: 1px white solid;
border-radius: 50px;
}
.completed {
font-size: 20px;
font-family: Montserrat;
border-bottom: 2px skyblue solid;
border-radius: 5px;
margin: 0px;
padding: 0px;
}
.navbar a {
letter-spacing: -2px;
color: white;
font-size: 20px;
font-family: Montserrat;
text-decoration: none;
}
.navbar a:hover {
color: skyblue;
}
.company_info {
display: flex;
justify-content: space-around;
align-items: center;
background-color: #323a42;
}
.company_text {
display: flex;
flex-direction: column;
width: 500px;
padding: 50px;
}
.infoCompany {
background-image: url("./images/companyBack.jpeg");
background-position: center center;
background-size: cover;
width: 100%;
height: 600px;
}
.infoCompany__Text {
display: flex;
flex-direction: column;
color: white;
width: 100%;
font-size: 26px;
}
.infoCompany__Text_Company {
display: flex;
margin-top: 100px;
margin-left: 200px;
}
.Service {
color: white;
font-size: 24px;
text-align: center;
}
.Service__Products {
display: flex;
flex-wrap: wrap;
}
.Service__Products_Product {
width: 100%;
display: flex;
flex-direction: column;
margin: 50px 0 0 0;
}
.Product__img {
width: 400px;
height: 302px;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.Product__downPartCard {
display: flex;
}
.Product__leftDivCard {
width: 12px;
height: 98px;
background-color: #1A81AD;
}
.Product__NameCardDiv {
width: 388px;
height: 98px;
background: white;
}
.Product__DownPartCard_Text {
font-size: 15px;
display: flex;
color: black;
padding-left: 15px;
padding-top: 30px;
}
.Garant {
color: white;
margin-top: 100px;
margin-left: 200px;
margin-right: 200px;
color: white;
font-size: 24px;
}
.Garant__Garants {
margin-top: 70px;
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.Garant__Card {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.Gatant__Card_Img {
width: 150px;
height: 150px;
}
.Gatant__Card_Text {
font-size: 16px;
}
footer {
margin-top: 70px;
position: absolute;
width: 100%;
border-top: 1px white solid;
}
.invisible {
opacity: 0;
}
}
So "margin-left: 150px ;" from media 2560px somehow using in 1920px, why ?
.Service__products_Product:not(first-child) {
margin-left: 150px ;
}
/* Extra small devices (phones, 360px) to Large devices (laptops/desktops, 1920px) */
#media screen and (min-width: 360px) and (max-width: 1920px) { css here...}
/* Extra Large devices (laptops/desktops, 1921px and up) */
#media screen and (min-width: 1921px) {css here...}
/* 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%;
I'm following some tutorials to do some coding, and I've found that for some reason, when i use the ::before pseudo attribute, and try to set the background color of it, nothing is visible.
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #1d061a;
font-family: consolas;
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
padding: 40px 0;
}
.container .box {
position: relative;
width: 320px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
margin: 40px 30px;
transition: 0.5s;
}
.container .box::before {
content: '';
position: absolute;
top: 0;
left: 50px;
width: 50%;
height: 100%
background: #fff;
border-radius: 8px;
transform: skewX(15deg);
transition: 0.5s;
}
(I couldn't figure out how to get the code to display correctly)
Little syntax error; all that was missing was a " ; " after your height declaration in the ::before selector, causing your background-color to not be picked up.
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #1d061a;
font-family: consolas;
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
padding: 40px 0;
}
.container .box {
position: relative;
width: 320px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
margin: 40px 30px;
transition: 0.5s;
}
.container .box::before {
content: '';
position: absolute;
top: 0;
left: 50px;
width: 50%;
height: 100%;
background: #fff;
border-radius: 8px;
transform: skewX(15deg);
transition: 0.5s;
}
<div class="container">
<div class="box"></div>
</div>
You've got some error in your ::before missing a ; after height declaration.
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #1d061a;
font-family: consolas;
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
padding: 40px 0;
}
.container .box {
position: relative;
width: 320px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
margin: 40px 30px;
transition: 0.5s;
background: #f00;
}
.container .box::before {
content: '';
position: absolute;
top: 0;
left: 50px;
width: 50%;
height: 100%;
display: block;
background: #fff;
border-radius: 8px;
transform: skewX(15deg);
transition: 0.5s;
}
<div class="container">
<div class="box"></div>
</div>
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 {
}```