I don't understand why the text is going under the image before flex wrap comes into play. I know it's probably something simple but I just can't figure it out.. I have put widths on both sides of the page, but they seem to be ignored when it comes to resizing, and the text goes almost completely behind the image before flex wrap drops it below (I want the image to be on top when that happens but I'll cross that bridge when I come to it, assuming I'll use a reverse property in flex). Anyway, not sure what is going on, and apologies for the probable mess of HTML and CSS.
Thanks
<div class="layout">
<div class="left-sect">
<img class="logo" src="./images/logo.svg" alt="site logo" />
<div class="l-content">
<h1 class="s-head">We're</h1>
<h1>
Coming <br />
Soon
</h1>
<p>
Hello fellow shoppers! We're currently building our new fashion
store. Add your email below to stay up-to-date with announcements
and our launch deals.
</p>
<input type="email" class="main-form" />
<button type="submit">
<img src="./images/icon-arrow.svg" alt="form button arrow" />
</button>
</div>
</div>
<div class="right-sect">
<img class="main-img" src="./images/hero-desktop.jpg" alt="" />
</div>
</div>
</body>
CSS
:root {
--ds-red: hsl(0, 36%, 70%);
--soft-red: hsl(0, 93%, 68%);
--dg-red: hsl(0, 6%, 24%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
font-family: "Josefin Sans", sans-serif;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
}
.layout {
display: flex;
flex-direction: row;
/* flex-wrap: wrap; */
}
.left-sect {
padding: 4rem 10rem;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
width: 60%;
}
.l-content {
margin-top: 7rem;
}
.main-img {
}
.s-head {
color: var(--ds-red);
font-weight: 300;
text-transform: uppercase;
font-size: 4rem;
letter-spacing: 1.2rem;
}
h1 {
font-size: 4rem;
letter-spacing: 1.2rem;
text-transform: uppercase;
color: var(--dg-red);
font-weight: 400;
}
p {
color: var(--ds-red);
text-emphasis: left;
width: 30rem;
line-height: 1.3rem;
margin-top: 1.5rem;
}
You sould add media queries.
:root {
--ds-red: hsl(0, 36%, 70%);
--soft-red: hsl(0, 93%, 68%);
--dg-red: hsl(0, 6%, 24%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
font-family: "Josefin Sans", sans-serif;
background-size: cover;
background-position: center;
}
.layout {
display: flex;
}
.left-sect {
padding: 4rem 10rem;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
width: 60%;
}
.l-content {
margin-top: 7rem;
}
.main-img {
}
.s-head {
color: var(--ds-red);
font-weight: 300;
text-transform: uppercase;
font-size: 4rem;
letter-spacing: 1.2rem;
}
h1 {
font-size: 4rem;
letter-spacing: 1.2rem;
text-transform: uppercase;
color: var(--dg-red);
font-weight: 400;
}
p {
color: var(--ds-red);
text-emphasis: left;
width: 30rem;
line-height: 1.3rem;
margin-top: 1.5rem;
}
#media screen and (max-width:1070px){/* <== You sould change this to what you want.*/
html .layout{
flex-direction:column;
}
#media screen and(min-width:1017px){ /* <== You sould change this to what you want.*/
html .layout{
flex-direction:row;
}
}
<div class="layout">
<div class="left-sect">
<img class="logo" src="https://image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="site logo" />
<div class="l-content">
<h1 class="s-head">We're</h1>
<h1>
Coming <br />
Soon
</h1>
<p>
Hello fellow shoppers! We're currently building our new fashion
store. Add your email below to stay up-to-date with announcements
and our launch deals.
</p>
<input type="email" class="main-form" />
<button type="submit">
<img src="./images/icon-arrow.svg" alt="form button arrow" />
</button>
</div>
</div>
<div class="right-sect">
<img class="main-img" src="https://image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="" />
</div>
Related
So I'm relatively new to Css and trying to learn it by doing some projects , I'm almost through with this one , but the thing that I'm not getting right is that the image is not taking up the same height as that of the left div , why is this so , even though I have set the height of left container to be 100% of the main container
I'm attaching the code for your reference
#import url(https://fonts.google.com/specimen/Fraunces);
#import url(https://fonts.google.com/specimen/Montserrat);
:root {
--Dark-cyan: hsl(158, 36%, 37%);
--Cream: hsl(30, 38%, 92%);
--Very-dark-blue: hsl(212, 21%, 14%);
--Dark-grayish-blue: hsl(228, 12%, 48%);
--White: hsl(0, 0%, 100%)
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 14px;
background-color: var(--Cream);
color: black;
}
.container {
background-color: var(--White);
width: 33%;
height: 33%;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
margin: 4rem auto;
}
.left-side {
width: 50%;
background-size: cover;
background-position: center;
height: 100%;
overflow: hidden;
}
.left-side img {
width: 100%;
object-fit: cover;
}
.right-side {
width: 50%;
height: 100%;
padding: 2rem;
}
h5 {
font-family: "Montserrat", sans-serif;
font-weight: 500;
letter-spacing: 0.4rem;
color: var(--Dark-grayish-blue);
margin: 0 0 2em 0;
}
h1 {
font-family: "Fraunces", serif;
font-weight: 700;
letter-spacing: 0.07rem;
}
.content {
font-family: "Fraunces", serif;
font-weight: 500;
color: var(--Dark-grayish-blue);
margin: 1.75em 0;
line-height: 1.5;
}
.prices {
font-family: "Fraunces", serif;
display: inline;
margin: 0 0.5em;
}
.old-price {
text-decoration: line-through;
}
.new-price {
font-weight: 700;
color: var(--Dark-cyan);
}
.btn {
padding: 0.5em 1.8em;
background-color: var(--Dark-cyan);
color: var(--White);
width: 95%;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 1.75em 0 0 0;
}
.btn:hover {
opacity: 0.5;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Frontend Mentor | Product preview card component</title>
</head>
<body>
<section class="main-body">
<div class="container">
<div class="left-side">
<img src="https://images.unsplash.com/photo-1611915387288-fd8d2f5f928b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80">
</div>
<div class="right-side">
<h5>PERFUME</h5>
<h1>Gabrielle Essence Eau De Parfum</h1>
<p class="content">A floral, solar and voluptous interpretation composed bu oliver polge,Perfumer-Creator for the house of chanel</p>
<div class="price">
<h1 class="new-price prices">$149.99</h1>
<p class="old-price prices">$169.99</p>
</div>
<button class="btn">
<i class="fa fa-shopping-cart" style="font-size:16px"></i> Add To Cart
</button>
</div>
</section>
</body>
</html>
.left-side{
width: 50%;
background-size: cover;
background-position: center;
height: 100%;
overflow: hidden;
}
.left-side img{
width:100%;
object-fit: cover;
Only thing i can think of is that you have given it two different properties, try combining these in the same css stack
.container {
/* ... */
align-items: stretch; /* Add this line */
}
.left-side {
/* ... */
height: 100%; /* <- Remove this line */
/* Add these two lines: */
min-height: 100%;
background-image: url("images/image-product-mobile.jpg");
}
Also, remove the <img /> from the left-side div; now it's on the CSS (.left-side), so you can cover and center the background.
Demo:
https://jsfiddle.net/adqb1v8r/
https://ibb.co/tL337vV
Look closely at the top right corner of the page you will see there is an empty space that I can't get rid of.
this only appears on actual phones and tablets not on desktop even if squeeze the browser.
<div class="banner">
<div class="banner-content">
<div class="banner-text">
<h1 class="welcoming"></h1>
</div>
</div>
</div>
*{
box-sizing: border-box;
padding: 0px;
margin: 0px;
}
html, body {
margin: 0;
}
body {
background-color: rgb(255, 253, 250);
}
/*header*/
.banner {
background-color: rgb(153, 217, 234);
max-height: 200px;
}
.banner-content {
padding: 20px;
align-items: center;
}
.banner-text {
flex-grow: 1;
line-height: 1.4;
}
.welcoming {
color: aliceblue;
text-align: center;
font-weight: bold;
font-size: 120px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif ;
text-transform: uppercase;
}
also you can see that the search bar isn't aligned properly, any suggestions?
<div class="wrapper">
<div class="search-input">
<a href="" target="_blank" hidden></a>
<input type="text" class="search-box" placeholder="Pick a topic, person, something">
<div class="autocom-box">
<!-- here list are inserted from javascript -->
</div>
<div class="icon"><i class="fas fa-search"></i></div>
</div>
</div>
.wrapper{
max-width: 810px;
margin: 150px auto;
}
.wrapper .search-input {
text-align: center;
margin: 15px;
}
.wrapper .search-input{
background: #fff;
width: 100%;
border-radius: 5px;
position: relative;
box-shadow: 0px 1px 5px 3px rgba(0,0,0,0.12);
font-family: 'Poppins', sans-serif;
}
Looks like something is causing an overflow on the page. One trick that I often use in such situation is going into dev tools and adding this style rule:
* {
background-color: rgba(2,2,240, 0.1) !important;
}
It lets you see every elements position and check which one is causing an overflow
Remove width: 100%; from your .wrapper .search-input class
Edit: I'm assuming you wanted to target your input field when applying the width: 100%;, so you could add this to your CSS:
.wrapper .search-box {
width: 100%;
}
#title {
text-align: center;
color: #643F37;
font-family: Arial;
}
h3 {
margin-left: 700px;
color: #643F37;
font-family: arial;
}
.image {
hight: 1000px;
width: 500px;
display: block;
margin: 0px auto;
postion: relative;
}
#main {
background: hsl(0, 1%, 90%);
font-family: times new roman;
font-size: 40px;
align-items: center;
}
#img-div {
#
}
#img-caption .image {
position: relative;
left: auto;
}
<head>
<h1 id="title">
The story of Clarnece Jordan
</h1>
<h3>
by clarence
</h3>
</head>
<body>
<main id="main">
<div id="img-div">
<img class="image" src="https://scontent-dfw5-2.xx.fbcdn.net/v/t1.6435-9/69294192_733858860396587_3589774459596177408_n.jpg?_nc_cat=107&ccb=1-3&_nc_sid=174925&_nc_ohc=vp-El7mg4WAAX_k529k&_nc_ht=scontent-dfw5-2.xx&oh=da307ba4e9977da7860d2dc87e333e85&oe=60926139">
</div>
<div id="img-caption">
<p> this is a picture is form church
<p>
</div>
</main>
</body>
You have to understant first the usage of html objects, I'd recommend you to take first a quick tutorial and be aware of the typos, this will make your development much easier. For your problem...
This site may help you with your specific problem: https://www.w3schools.com/TAGS/tag_figcaption.asp
This page is extremely useful for begginers and has a lot of tutorials.
Also I'd suggest to use classes instead of id's and make them reusable; for example:
.text-center {
text-align: center;
}
.title {
text-align: center;
color: #643F37;
font-family: Arial;
}
.subtitle {
color: #643F37;
font-family: arial;
}
.image {
height: 1000px;
width: auto;
display: block;
margin: 0px auto;
}
.main {
background: hsl(0, 1%, 90%);
font-family: times new roman;
font-size: 40px;
align-items: center;
}
figcaption {
font-style: italic;
padding: 2px;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Clarnece Jordan</title>
</head>
<body>
<div class="main">
<h1 class="title text-center">The story of Clarnece Jordan </h1>
<h3 class="text-center subtitle">by clarence</h3>
<div>
<img class="image" src="https://scontent-dfw5-2.xx.fbcdn.net/v/t1.6435-9/69294192_733858860396587_3589774459596177408_n.jpg?_nc_cat=107&ccb=1-3&_nc_sid=174925&_nc_ohc=vp-El7mg4WAAX_k529k&_nc_ht=scontent-dfw5-2.xx&oh=da307ba4e9977da7860d2dc87e333e85&oe=60926139">
<figcaption>This is a picture is form church</figcaption>
</div>
</div>
</body>
</html>
This site might be helpful: https://www.lifewire.com/caption-that-stays-with-image-3467838 .
Steps to an HTML Image Caption
Add an image to your webpage.
In the HTML for your webpage, place a div tag around the image:
Add a style attribute to the div tag:
Set the width of the div to the same width as the image, with the width style property:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#import "variables";
#import "utilities";
body {
color: $neutral;
font-family: "Open Sans", sans-serif;
background-color: $main-bg;
}
a {
color: $cyan;
text-decoration: none;
}
ul {
list-style: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Raleway", sans-serif;
}
p {
font-family: "Raleway", sans-serif;
}
#header {
grid-area: heading;
height: 100vh;
background-color: $intro-email;
position: relative;
background-image: $bg-image;
background-size: contain;
background-repeat: no-repeat;
background-position: left bottom;
// &::before {
// content: "";
// background-image: $bg-image;
// position: absolute;
// width: 100%;
// background-size: contain;
// background-repeat: no-repeat;
// background-position: left bottom;
// }
.navbar {
grid-area: heading;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6rem;
.nav-list {
display: flex;
li {
padding: 1rem 1.2rem;
text-transform: uppercase;
a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
border-bottom: 3px transparent solid;
padding-bottom: 0.5rem;
transition: border-color 0.5s;
font-size: 0.8rem;
font-weight: 400;
font-family: "Raleway", sans-serif;
&:hover {
border-color: #fff;
}
&.current {
border-color: #fff;
}
}
}
}
}
.header-content {
max-width: 100%;
margin: 20px auto;
text-align: center;
width: 600px;
img {
max-width: 90%;
margin-top: -50px;
}
}
}
Variabes for CSS $intro-email: hsl(217, 28%, 15%);
$main-bg: hsl(218, 28%, 13%);
$footer-bg: hsl(216, 53%, 9%);
$testimonial-bg: hsl(219, 30%, 18%);
$neutral: hsl(0, 0%, 100%);
$cyan: hsl(176, 68%, 64%);
$blue: hsl(198, 60%, 50%);
$website-width: 1440px;
$bg-image: url("../img/bg-curvy-desktop.svg");
Container .container {
width: $website-width;
max-width: 100%;
padding: 2rem;
margin: 0 auto;
overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#400;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght#400;700&display=swap" rel="stylesheet" />
<header id="header">
<div class="container">
<div class="wrapper">
<nav class="navbar">
<img src="../dist/img/logo.svg" alt="" />
<ul class="nav-list">
<li>Features</li>
<li>Team</li>
<li>SignIn</li>
</ul>
</nav>
<div class="header-content">
<img src="../dist/img/illustration-intro.png" alt="" />
<h1 class="title">
All your files in one secue location, accessible anywhere
</h1>
<p class="text">
Flyo stores all your most important files in one secure location. Access them whenever you need, share and collaborate with friends, family and co-workers
</p>
<button class="btn-main">Get Started</button>
</div>
</div>
</div>[Image showing what is happening in my code][1]
</header>
Website width is set to 1440px but anytime i move to the mobile version on my screen, width of the website is never the same and some elements of the website begin to fall out of place of the website, is there a way to fix this or should i remove the container that i am nesting the elements in because that is the website width the design was made for
For your container, consider using a responsive width like width: 100vw (i.e. 100% of viewport/window width). Or, if you really want to stick with 1440px, you can use media queries.
Media queries help applying different CSS rules to different device screen sizes, as a dummy example:
#media(max-width: 599px) {
.container {
/* Your styling for mobile phones */
}
}
#media(min-width: 600px) {
/* Your styling for desktops */
}
I am trying to get the Texas icon directly centered between the span and h1 element.
Here is the Screen Capture
I tried googling but I think I might be phrasing what I need poorly. Is it that I have to adjust the padding and margin in css? I just want to move the icon down the y-axis.
Thank you
<header id="top" class="main-header">
<span class="title">Keep it Weird in</span>
<div>
<img class="texas-icon" src="https://image.ibb.co/cGRVFG/texasicon_1.png" alt="texasicon_1" border="0"></a>
</div>
<h1>Austin</h1>
.main-header {
padding-top: 170px;
height: 850px;
background: linear-gradient(lightblue, transparent 90%),
linear-gradient(0deg, #fff, transparent),
#ffa949 url('https://media.giphy.com/media/3ohs7I9ho0H4dfeP7y/giphy.gif') no-repeat center;
background-size: cover;
}
.title {
color: white;
font-size: 1.625rem; /* 26px/16px */
letter-spacing: .065em;
font-weight: 200px;
padding-bottom: 10px;
}
h1 {
font-size: 12.5rem; /* 90px/16px */
color: rgba(255, 255, 255, 1);
text-transform: capitalize;
font-weight: normal;
text-align: center;
line-height: 1.3;
margin: 12px 0px 0px;
}
I think text-align:center is enough in your case, then simply play with margin of elements to create the spaces :
header {
background: blue;
text-align: center;
color: #fff;
max-height: 380px;
padding: 50px 25px 0px;
}
.title {
margin: 5px 0;
font-size: 1.3rem;
border: none;
display: inline-block;
}
h1 {
margin: 10px 0;
font-size: 5rem;
line-height: 1.1;
}
<header id="top" class="main-header">
<span class="title">Keep it Weird in</span>
<div>
<img class="texas-icon" src="https://image.ibb.co/cGRVFG/texasicon_1.png" alt="texasicon_1" border="0">
</div>
<h1>Austin</h1>
</header>
Thank you for the support. Unfortunately, none of the solutions worked but I decided just to change the line height of the h1 element and was able to get the result I wanted. I learned so many new things from the responses to my question. Again, thank you.
Updated Screen Capture