Right now the text aligns underneath the image. I want the text to be beside the image vertically. I tried to add flex-direction: column and justify-content: center but it's not working. I also tried float and it didn't work. I can't figure out how to align the text and image side by side. How can I make it so that they align beside each other? Are there errors in my code?
.whoweare {
padding: 80px 0px 50px;
background-color: #000000;
}
.whoweare #whoweareimg {
width: 100%;
min-width: 200px;
}
.whoweare .content {
-webkit-display: flex;
display: flex;
flex-wrap: wrap;
/* flex-direction: column; */
/* justify-content: center; */
}
.whoweare .content .box {
/* padding:5px;
flex:0 0 100%;
max-width: 100%; */
padding: 5px;
flex: 0 0 100%;
max-width: 100%;
}
.whoweare .content #whoweareimg {
width: 50%;
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
padding: 30px;
}
.whoweare .content h2 {
font-size: 50px;
font-weight: 500;
margin: 20px;
color: #ffffff;
padding: 0px 0px 20px;
}
.whoweare .content p {
font-size: 20px;
line-height: 50px;
color: #ffffff;
margin: 20px;
padding: 0px 0px 20px;
font-family: 'Open Sans', sans-serif;
}
<section class="whoweare" id="whoweare">
<div class="container">
<div class="content">
<div class="box text wow slideInRight">
<!-- <div class="class-items"> -->
<div class="item wow bounceInUp">
<!-- <div class="item-img"> -->
<img id="whoweareimg" src="https://via.placeholder.com/50" alt="classes" />
</div>
<div class="box text wow slideInRight">
<h2>Who we are</h2>
<p>UNDRGRND Muscle & Fitness, where street culture meets the bodybuilding and fitness lifestyle. Our goal is to provide our members with a unique state of the art training experience in the Vaughan/GTA.
</br>
</br>
Experience a one of a kind training atmosphere to help fuel workouts like no other. Exclusive training sessions from IFBB pro athletes will be available in order for members to reach their lifestyle and/or contest prep goals. The facility will provide the best fitness equipment on the market ranging from Atlantis, Cyber, Arsenal, and more.
</br>
</br>
We are all part of a family and all in this together here at UNDRNRGD.</p>
</div>
</div>
</div>
</div>
</section>
Your HTML seems wrong because there was a <div class="box text wow slideInRight"> nested inside another, but in any case here is the code I came up with to solve your problem.
The idea is that .whoweare .content .box:first-child is your flex container, and its two children (<div class="item wow bounceInUp"> and the other <div class="box text wow slideInRight">) will be aligned side by side.
.whoweare {
padding: 80px 0px 50px;
background-color: #000000;
}
.whoweare #whoweareimg {
width: 100%;
min-width: 200px;
}
.whoweare .content .box {
padding: 5px;
max-width: 100%;
}
.whoweare .content .box:first-child {
display: flex;
}
.whoweare .content #whoweareimg {
width: 50%;
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
padding: 30px;
}
.whoweare .content h2 {
font-size: 50px;
font-weight: 500;
margin: 20px;
color: #ffffff;
padding: 0px 0px 20px;
}
.whoweare .content p {
font-size: 20px;
line-height: 50px;
color: #ffffff;
margin: 20px;
padding: 0px 0px 20px;
font-family: 'Open Sans', sans-serif;
}
<section class="whoweare" id="whoweare">
<div class="container">
<div class="content">
<div class="box text wow slideInRight">
<!-- <div class="class-items"> -->
<div class="item wow bounceInUp">
<!-- <div class="item-img"> -->
<img id="whoweareimg" src="https://via.placeholder.com/50" alt="classes" />
</div>
<div class="box text wow slideInRight">
<h2>Who we are</h2>
<p>UNDRGRND Muscle & Fitness, where street culture meets the bodybuilding and fitness lifestyle. Our goal is to provide our members with a unique state of the art training experience in the Vaughan/GTA.
</br>
</br>
Experience a one of a kind training atmosphere to help fuel workouts like no other. Exclusive training sessions from IFBB pro athletes will be available in order for members to reach their lifestyle and/or contest prep goals. The facility will provide the best fitness equipment on the market ranging from Atlantis, Cyber, Arsenal, and more.
</br>
</br>
We are all part of a family and all in this together here at UNDRNRGD.</p>
</div>
</div>
</div>
</div>
</section>
<!-- begin snippet: js hide: false console: true babel: false -->
<div class="content">
<div>
<img id="whoweareimg" src="https://via.placeholder.com/50x250" alt="classes" />
</div>
<div>
<h2>Who we are</h2>
<p>UNDRGRND Muscle & Fitness, where street culture meets the bodybuilding and fitness lifestyle. Our goal is to provide our members with a unique state of the art training experience in the Vaughan/GTA.
<br>
<br> Experience a one of a kind training atmosphere to help fuel workouts like no other. Exclusive training sessions from IFBB pro athletes will be available in order for members to reach their lifestyle and/or contest prep goals. The facility will
provide the best fitness equipment on the market ranging from Atlantis, Cyber, Arsenal, and more.
<br>
<br> We are all part of a family and all in this together here at UNDRNRGD.</p>
</div>
</div>
Related
SO I want to reach this image
But i am getting this result, and i have a sense that i misused boostrap for the grid, but i am not sure it has to do with my initial problem
I want to reach a parallax element too by translating the image on the x axis on click as in this gif So i am worried if using margin would make it worse
EDIT: my problem isn't with the grid and text placement, i want to position the trees ( right and left on the right sides) which isn't working at all. I know it is immature to say this but idc of the grid if its work like in the prototype
here is my code
<section id="abtus">
</span>
<div class="col-4" style="margin-bottom: 700px;"><img class="tree" src="./images/tree1.png" width="750"></div>
<div class="grid text-center " >
<div class="cols-4 pb-3"><p class="text1">WHO WE ARE</p></div>
<div class="cols-4 p-1 "><p class="text2">We are two sisters who come from a similar <br>
background of love for everything creative and magical.</p> </div>
<div class="cols-4 p-1 "> <p class="text2">We aim to deliver your stories with interesting <br>
visually pleasing magic that separates you from the rest!</p></div>
<div class=" cols-4 p-1 pb-5 "> <p class="text2">To guarantee great quality work and also an added fun <br>
element to your project.</p></div>
<div class="cols-1"><img src="./images/Group 33.svg"></div>
</div>
<div class="grid px-5">
<div class="cols-4 offset-md-2"><img src="./images/Group 30.svg" width="90"> </div>
<div class=" cols-4 pb-4"></div>
<div class=" cols-4 pb-2"></div>
<div class=" cols-4"><img src="./images/Group 46.svg" width="150"></div>
</div>
<div class="grid text-center">
<div class="cols-4 pb-3"><p class="text1">THE TEAM</p></div>
<div class="cols-4 pb-5"><p class="text2 pb-4">We have a rich experience in the market, especially <br>
in gaming and animation. We work with several tasks <br>
such as visual development, concept art, character design, <br>
graphic design, branding, and social media.<br><br>
Yes, We do everything!</p> </div>
<div class=" cols-4 pb-4"></div>
<div class=" cols-4 text-center"><img src="./images/Group 50.svg" width="120"></div>
</div>
</span>
</section>
the relative css
section{
flex: none;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
scroll-snap-align: start;
}
.tree{
top: 0;
left:0;
position:absolute ;
z-index: 1;
}
.text1{
text-align: left;
left: 0;
color: #20122B;
font-family: 'Lato';
font-weight: 900;
font-size: 30px;
}
.text2{
text-align: left;
color: #20122B;
font-family: 'Lato';
font-weight: 500;
font-size: 0.9em;
line-height: 16px;
}
.arrow1{
display: grid;
place-items: center;
place-content: center;
border-left: 3px solid #ffffff;
border-bottom: 3px solid #ffffff;
width: 10px;
height: 10px;
border-radius: 0.2em;
transform: rotate(225deg);
}
.right{
margin-right: 150px;
float:left;
}
.left{
margin-right: 100px;
float:left;
transform: rotate(45deg);
}
I have been trying very hard to make a split screen using Bootstrap. Here's what it looks like when I managed to do it with CSS:
But I need to make it responsive to mobile users so I'm remaking it with Bootstrap. However the image and textbox don't resize for some reason.
By responsive I mean that it should become single row with 2 columns and vice versa depending wether you're on a desktop or mobile.
Edit: Sorry for this sudden change, but I'm now using Bootstap ver5.
#promotion-textbox {
top: 115px;
display: inline-block;
margin-right: 5vw;
left: 55%;
background-color: white;
object-fit: fill;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#promotion-title {
padding: 10px;
position: static;
color: #23272a;
font-size: 3vw;
overflow: hidden;
display: inline-block;
}
#promotion-button {
width: 40vw;
opacity: 0.8;
left: 75%;
transform: translate(-50%, -75%);
margin-left: auto;
margin-right: auto;
top: 620px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<div class="row">
<!-- First Half -->
<div class="col-md-6">
<img class="img" src="https://via.placeholder.com/100">
</div>
<!-- Second Half -->
<div class="col-md-6">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
</div>
</div>
A few things, if you are using a library then take advantage of it, use its utility classes, and learn its grid system:
Add vh-100 utility class to your row
Add w-100 h-100 in img tag HTML and in CSS add object-fit: cover
Because you've updated your question from bootstrap-4 to ootstrap-5, to remove the spacing in order to hide the horizontal scrollbar you need to replace no-gutters to g-0
Note: You have a lot of styles that doesn't make sense, such left/top without position
I also I've improved your code
#promotion-textbox {
background-color: white;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
margin-bottom: 20px;
}
#promotion-title {
padding: 10px;
color: #23272a;
font-size: 3vw;
}
#promotion-button {
opacity: 0.8;
border: 2px solid #fff;
color: #fff;
padding: 10px 20px;
background: transparent;
}
img {
object-fit: cover
}
.col-6:last-child {
background: darkgray
}
.promotion-column {
display: flex;
flex-direction: column;
padding: 20px;
align-items: center;
justify-content: center;
height: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="row g-0 vh-100">
<!-- First Half -->
<div class="col-md-6">
<img class="img w-100 h-100" src="https://picsum.photos/300/200">
</div>
<!-- Second Half -->
<div class="col-md-6">
<div class="promotion-column">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
<button type="button" id="promotion-button">All Projects</button>
</div>
</div>
</div>
You must use responsive image if you want it to be responsive. I also removed gutters from the row.
EDIT: made some improvment, height:100vh is really helpful. Takes exactly the height of the window.
.half {
border: 1px solid red;
height: 100vh;
position: relative;
}
.my-image {
width: 100%;
height: 100%;
}
#promotion-textbox {
top: 115px;
display: inline-block;
background-color: white;
object-fit: fill;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#promotion-title {
padding: 10px;
position: static;
color: #23272a;
font-size: 3vw;
overflow: hidden;
display: inline-block;
}
#promotion-button {
width: 40vw;
opacity: 0.8;
left: 75%;
transform: translate(-50%, -75%);
margin-left: auto;
margin-right: auto;
top: 620px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="row no-gutters">
<!-- First Half -->
<div class="half col-sm-6">
<img class="img my-image" src="https://picsum.photos/536/354">
</div>
<!-- Second Half -->
<div class="half col-sm-6">
<div id="promotion-textbox">
<div id="promotion-title">
Duck Zone is the best game of all time, I mean just look at these awesome reviews:<br /><br /> TheP0mp21 Says:<br />- Game is pretty good but it needs a your mum duck that is extremely fat and spawns other ducks.
</div>
</div>
</div>
</div>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
<p>content </p>
To make a split screen (two columns) use .row as parent and .col-md-6 for children. "md" part means that columns will expand to full screen width on medium and smaller screens( you can choose: xxl, xl, lg, md, sm, xs). TO make it fit the screen vertically add min-height: 100vh; for both columns and media query for the break point with min-height: 50vh;
source: https://getbootstrap.com/docs/4.6/layout/grid/
Bootstrap 4 example (works in bootstrap 5 and 4):
CSS:
.img-col{
background: url(https://via.placeholder.com/100) center center no-repeat;
background-size: cover;
}
.min-h-50{
min-height:100vh;
}
#media only screen and (max-width: 767px) {
.min-h-50{
min-height:50vh;
}
}
HTML:
<div class="row">
<div class="col-md-6 img-col min-h-50">
</div>
<div class="col-md-6 bg-dark min-h-50">
<div class="row justify-content-center h-100">
<div class="col-10 align-self-center">
<div class="bg-white p-3">rff</div>
<div class="mt-3 text-center"><button class="btn btn-primary">xxx</button></div>
</div>
</div>
</div>
</div>
I am a beginner and doing my first easy challenge, but I got stuck anyway :D
I want to move the text down, to the next line.
In particular, I want to make the text like this:
Final result
<div class="container">
<img src="/image-qr-code.png" alt="" />
<p class="main">Improve your front-end skills by building projects</p>
<p class="second">
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>
The p element will wrap automatically when there is a static width on the parent. This can also be done by using a static max-width on the element you want to constrain. You can also use margin to constrain the text relative to its parent. In your case, I used margin on second and main to allow the text to match the image you provided. Here is a simple demonstration:
.container {
box-shadow: 1px 1px 13px 7px rgb(200 198 198);
width: 240px;
max-width: 240px;
padding: 1em;
border-radius: 5px;
margin: auto;
}
.contain {
background-color: blue;
border-radius: 5px;
display: flex;
justify-content: center;
padding: 1em;
}
img {
max-width: 100%;
}
.main {
font-weight: bold;
text-align: center;
margin: 1em 2em;
}
.second {
text-align: center;
margin: 1em 1em;
}
<div class="container">
<div class="contain">
<img src="https://dummyimage.com/150/000/fff&text=QR+CODE" https://stackoverflow.com/questions/72034538/how-can-i-move-text-to-the-next-line# alt="" />
</div>
<p class="main">Improve your front-end skills by building projects</p>
<p class="second">
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>
What you can do is put them separate divs
This will put the words in another line.
If what you mean was that the text does not overflow, that would include CSS>
Here is some of the code
html,
body {
margin: 0;
padding: 0;
background-color: rgb(174, 220, 239);
}
.container {
display: grid;
place-items: center;
padding-top: 300px;
}
form {
background-color: white;
width: 270px;
padding: 20px;
padding-top: 90px;
}
<div class="container">
<form action="">
<img src="/image-qr-code.png" alt="" />
<p class="main">Improve your front-end skills by building projects</p>
<div class="second">
<p>
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>
</form>
</div>
I am trying to style the gif by giving it border-radius. However ther gif is smaller than the column itself so border-radius is aplied only to the right side of the gif. Could anyone help me out in applying it to the left side aswell? I dont want to change the background-size: contain!important; because then I will loose the proportions of the gif.
PS. Snippet breakes the row and the gif is in another row but it doesn't matter in this example.
.half-half-image-text {
padding: 70px 0px;
}
.half-half-image-text h1 {
color: #800000;
}
.half-half-image-text .content {
height: 100%;
display: flex;
align-items: center;
padding: 35px 0px;
}
.half-half-image-text .content p {
font-size: 22px;
}
.half-half-image-text .img {
min-height: 320px;
height: 100%;
border-radius: 10px;
}
<!-- begin snippet: js hide: false console: true babel: false -->
<div class="half-half-image-text">
<div class="container" >
<div class="row">
<div class="col-7 col-lg-7" style="padding-right:0">
<div class="content">
<p>At Fluid Automotive, our purpose is to make automotive parts easily accessible for everyone. Working with our partner brands, we aim to retail the highest quality parts, whilst maintaining a high level of customer satisfaction.</p>
</div>
</div>
<div class="col-5 col-lg-5" style="padding-right:0">
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif" data-gallery="portfolioGallery" class="portfolio-lightbox">
<div class="img customzoom s2" style="background-size: contain!important;box-shadow: none;
background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif')no-repeat center right;background-size:cover;" alt="Plan rozwoju" title="Plan rozwoju"></div>
</a>
</div>
</div>
</div>
</div>
You could add this style to portfolio-lightbox :
width: 240px;
display: block;
and change min-height:320px; to min-height:240px will solve your problem. Like below :
half-half-image-text {
padding: 70px 0px;
}
.half-half-image-text h1 {
color: #800000;
}
.half-half-image-text .content {
height: 100%;
display: flex;
align-items: center;
padding: 35px 0px;
}
.half-half-image-text .content p {
font-size: 22px;
}
.half-half-image-text .img {
min-height: 240px;
height: 100%;
border-radius: 10px;
}
.portfolio-lightbox {
width: 240px;
display: block;
}
<div class="half-half-image-text">
<div class="container" >
<div class="row">
<div class="col-7 col-lg-7" style="padding-right:0">
<div class="content">
<p>At Fluid Automotive, our purpose is to make automotive parts easily accessible for everyone. Working with our partner brands, we aim to retail the highest quality parts, whilst maintaining a high level of customer satisfaction.</p>
</div>
</div>
<div class="col-5 col-lg-5" style="padding-right:0">
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif" data-gallery="portfolioGallery" class="portfolio-lightbox">
<div class="img customzoom s2" style="background-size: contain!important;box-shadow: none;
background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif')no-repeat center right;background-size:cover;" alt="Plan rozwoju" title="Plan rozwoju"></div>
</a>
</div>
</div>
</div>
</div>
Simply use an image tag.
.imgradius {
border-radius: 10px
}
<img class="imgradius" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif"></img>
I'm having a tough time keeping my content centered within a certain width on my personal website. I have tried many methods such as setting body to a fix width and my wrapper container to a percentage of that. I have attached a picture of my website here and highlighted where I want my content to be contained in the picture shown
.
I want my content of my website centered within that highlighted area, while at the same time keeping the background to be the full size of the screen.
I realize this may be a simple question for many, but I have spent all day looking for and trying out different methods to do this with no avail.
body {
background-color: #F0f0f0;
text-align: center;
margin-right: 0px;
margin-left: 0px;
}
.wrapper {
text-align: center;
}
.topSection {
height: 300px;
border: solid 5px;
}
.mainAbout {
padding-left: 50px;
padding-right: 50px;
vertical-align: middle;
}
.mainAbout h1 {
font-size: 60px;
font-family: arvo, sans-serif;
margin-bottom: 5px;
}
#leftBrace {
vertical-align: middle;
}
#rightBrace {
vertical-align: middle;
}
.projects {
height: 864px;
border: solid 5px;
margin-top: 2px;
background: #0F1217;
}
.projects h2 {
color: #e6e6e6;
font-family: arvo, sans-serif;
font-size: 50px;
}
<link href="https://fonts.googleapis.com/css?family=Arvo" rel="stylesheet">
<div class="wrapper">
<!---- Wrapper Starts Here --->
<div class="topSection" style="display:block" ;>
<!---- Name Section Starts Here --->
<div id="leftBrace" style="display: inline-block" ;>
<img src="leftbrace.png">
</div>
<div class="mainAbout" style="display: inline-block" ;>
<!--- Main Name and About me Section ---->
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
<!--- End mainAbout --->
<div id="rightBrace" style="display: inline-block" ;>
<img src="rightbrace.png">
</div>
</div>
<!--- Wrapper Ends Here --->
<div class="projects">
<h2> Projects </h2>
</div>
<div class="contact">
</div>
</div>
<!--- Wrapper Ends Here --->
<footer>
</footer>
Instead of using background you could style curly-braces using pseudo selector :before and :after, thus it works like font styling, you could use transform:translate to center your intro text container, check below codes.
#box {
width: 100%;
height: 300px;
overflow: hidden;
background: #ccc;
}
#box > .cnt {
width:50%;
text-align: center;
top: 50%;
left: 50%;
position: relative;
transform: translate(-50%, -50%);
}
#box:before {
content:"{";
font-size: 250px;
position: absolute;
top: 0;
left:10%;
}
#box:after {
content: "}";
font-size: 250px;
position: absolute;
top: 0;
right:10%;
}
<div id="box">
<div class="cnt">
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
</div>
Apply margin: 0 auto; to your content class. This will work.
You need to make sure add an inner class inside each wrapper and define your desired width. And need to apply margin: 0 auto to the inner. I added demo snippet.If u want specific wrapper full width just remove innerclass that's enough you will get full width. I hope it will help you.
.wrapper {
height: 300px;
width: 100%;
background: orange;
margin-bottom: 20px;
}
.inner {
width: 70%;
margin: 0 auto;
background: pink;
height: 100%;
}
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>