I have some problems laying out my elements. I tried to achieve the following layout in my web application:
I tried to use div´s and style them but it looks like this when I run it
I wanted to create a grid with three container in each row. Also for responsiveness I used flexbox.
Any suggestions how the layout could improve? I think I messed it up a little.
.contacts-container {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
h1.subheading {
color: red;
}
.contact {
flex: 0 0 32%;
/* don't grow, don't shrink, width */
margin-bottom: 5px;
border: 1px solid #ddd;
}
.contact a {
color: black;
text-decoration: none;
}
.contactInfo {
padding: 1.4em;
float: left;
}
.contactInfo h2 {
margin-top: 0;
margin-bottom: 0.5em;
font-weight: normal;
}
.contactInfo p {
font-size: 95%;
}
.contactInfo .contactName {
float: right;
}
.contactDetails {
float: left;
}
.contactDetails img {
width: 50px;
height: 50px;
}
#contact .contact-buttons {
position: absolute;
bottom: 0;
left: 0;
}
/* Using flexbox with media queries to make the layout responsive*/
#media screen and (min-width: 40em) {
.contacts-container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: -1em;
}
.contact-info {
display: flex;
flex: 0 1 calc(50% - 0.5em);
margin-bottom: 1em;
}
}
#media screen and (min-width: 60em) {
.contacts-container {
margin-top: inherit;
}
.contact-info {
flex: 0 1 calc(33% - 1em);
margin-bottom: 2em;
}
}
<div class="contacts">
<h1 class="subheading">Deine Kontakte</h1>
<div class="contacts-container">
<div v-for="contact in contacts" class="contact" :key="contact.name">
<div class="contactInfo">
<img :src="getImage(contactImg)" />
<div class="contactName">
<p>Prename Surname</p>
<p>City</p>
<p>Country</p>
</div>
</div>
<div class="contactDetails">
<div>
<img :src="getImage(contactImg)" style="" /> test#test.com
</div>
<div>
<img :src="getImage(contactImg)" /> test#test.com
</div>
<div>
<img :src="getImage(contactImg)" /> test#test.com
</div>
</div>
<div class="contact-buttons">
<button v-on:click="counter += 1">Add 1</button>
<button v-on:click="counter += 1">Add 1</button>
</div>
</div>
</div>
</div>
.contacts {
width: 300px;
padding: 40px;
border: 1px solid black;
}
.contact {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.contact .contactInfo {
display: flex;
margin-bottom: 30px;
}
.contact .contactInfo img {}
.contact .contactInfo .contactName {
margin: auto 0;
margin-left: 30px;
}
.contact .contactDetails {
margin-bottom: 30px;
border: 1px solid black;
}
.contact .contactDetails div {
display: flex;
margin: 10px;
}
.contact .contactDetails div p {
margin-left: 30px;
}
.contact .contact-buttons {
width: 100%;
display: flex;
justify-content: space-between;
}
<div class="contacts">
<h1 class="subheading">Deine Kontakte</h1>
<div class="contacts-container">
<div v-for="contact in contacts" class="contact" :key="contact.name">
<div class="contactInfo">
<img src="https://via.placeholder.com/150" />
<div class="contactName">
<p>Prename Surname</p>
<p>City</p>
<p>Country</p>
</div>
</div>
<div class="contactDetails">
<div>
<img src="https://via.placeholder.com/50" />
<p>test#test.com</p>
</div>
<div>
<img src="https://via.placeholder.com/50" />
<p>test#test.com</p>
</div>
<div>
<img src="https://via.placeholder.com/50" />
<p>test#test.com</p>
</div>
</div>
<div class="contact-buttons">
<button v-on:click="counter += 1">Add 1</button>
<button v-on:click="counter += 1">Add 1</button>
</div>
</div>
</div>
</div>
.contact {
margin-bottom: 5px;
border: 1px solid #ddd;
padding: 10px;
}
.contactInfo {
display: flex;
align-items: center;
}
.contactDetails {
border: 1px solid #ddd;
padding: 10px;
}
.contactDetailsRow {
display: flex;
flex-wrap: nowrap;
align-items: center;
}
.contactName,
.contactDetailsRowName {
flex: 1;
padding-left: 10px;
}
.contact-buttons {
display: flex;
}
.contact-buttons > button {
flex: 1;
margin: 10px;
}
<div class="contact">
<div class="contactInfo">
<div>
<img src="https://via.placeholder.com/100" />
</div>
<div class="contactName">
<h5>Prename Surname</h5>
<p>City</p>
<p>Country</p>
</div>
</div>
<div class="contactDetails">
<div class="contactDetailsRow">
<div>
<img src="https://via.placeholder.com/50"/>
</div>
<div class="contactDetailsRowName">
test#test.com
</div>
</div>
<div class="contactDetailsRow">
<div>
<img src="https://via.placeholder.com/50"/>
</div>
<div class="contactDetailsRowName">
test#test.com
</div>
</div>
<div class="contactDetailsRow">
<div>
<img src="https://via.placeholder.com/50"/>
</div>
<div class="contactDetailsRowName">
test#test.com
</div>
</div>
</div>
<div class="contact-buttons">
<button>Add 1</button>
<button>Add 1</button>
</div>
</div>
Been a while but something like this?
:root {
--baseMargin: 1.4em;
--buttonBorderRadius: 0.5em 0.5em 0.5em 0.5em;
--paddingBaseFill: calc(var(--baseMargin) * 2);
}
.contactInfo img {
min-width: 10em;
}
.contacts-container {
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: space-around;
}
h1.subheading {
color: red;
}
.contact {
flex: 0 1;
display: flex;
flex-direction: column;
/* don't grow, don't shrink, width */
margin-bottom: 5px;
border: 1px solid #ddd;
}
.wrapper {
margin: 0 var(--baseMargin);
}
.contact a {
color: black;
text-decoration: none;
}
.contactInfo {
flex: 1 1;
display: flex;
padding: var(--paddingBaseFill) 0;
}
.contactInfo h2 {
margin-top: 0;
margin-bottom: 0.5em;
font-weight: normal;
}
.contactInfo p {
font-size: 95%;
}
.contactInfo .contactName {
flex: 1 1;
margin-left: var(--baseMargin);
text-align: center;
}
.contactDetails {
flex: 1 1;
padding: 1em;
border: 0.1em solid black;
}
.contactDetails div {
display: flex;
align-items: center;
}
.contactDetails img {
width: 50px;
height: 50px;
padding: 0.5em;
}
.contact-buttons {
flex: 1 1;
display: flex;
justify-content: space-between;
padding: var(--baseMargin) 0;
}
.contact-buttons button {
font-size: 1.2em;
background: #018bff;
border-radius: var(--buttonBorderRadius);
padding: 0.25em;
color: #fff;
}
<div class="contacts">
<h1 class="subheading">Deine Kontakte</h1>
<div class="contacts-container">
<div v-for="contact in contacts" class="contact" :key="contact.name">
<div class="contactInfo wrapper">
<img :src="getImage(contactImg)" />
<div class="contactName">
<p>Prename Surname</p>
<p>City</p>
<p>Country</p>
</div>
</div>
<div class="contactDetails wrapper">
<div>
<img :src="getImage(contactImg)" style="" /> test#test.com
</div>
<div>
<img :src="getImage(contactImg)" /> test#test.com
</div>
<div>
<img :src="getImage(contactImg)" /> test#test.com
</div>
</div>
<div class="contact-buttons wrapper">
<button v-on:click="counter += 1">Add 1</button>
<button v-on:click="counter += 1">Add 1</button>
</div>
</div>
</div>
</div>
Related
I want to move the photo to top of the site and next to the text: "EMAIL :" Create a BITLAB NEWS layout web page using HTML + CSS
.top-bar {
background-color: #00008B;
color: white;
display: flex;
justify-content: space-between;
padding: 10px;
}
.top-bar .left {
color: white;
font-weight: bold;
font-size: 20px;
}
.top-bar .right {
color: white;
}
.login-bar {
display: flex;
justify-content: flex-start;
padding: 10px;
}
.login-bar .left {
color: black;
}
.input {
padding-left: 10px;
margin-bottom: 20px;
}
.password-bar {
display: flex;
justify-content: flex-start;
}
.password-bar .left {
color: black;
padding-left: 10px;
}
.input2 {
padding-left: 10px;
padding-top: 10px;
}
.button {
background-color: green;
margin-top: 20px;
margin-left: 10px;
color: white;
width: 60px;
border-radius: 5px;
height: 15px;
font-size: 12px;
text-align: center;
padding: 10px;
}
.blue {
color: #0000FF;
}
.center {
float: left;
width: 33.33%;
padding: 5px;
margin-left: 300px;
margin-bottom: 800px;
}
<div class="top-bar">
<div class="left">BITLAB NEWS</div>
<div class="right">About Contacts FAQ Login </div>
</div>
<body>
<div class="login-bar">
<div class="left">EMAIL :</div>
</div>
<div class="input"><input type="text" placeholder="Insert Email" style="width:200px; height: 25px;">
</div>
<div class="password-bar">
<div class="left">PASSWORD :</div>
</div>
<div class="input2"><input type="text" placeholder="Insert Password" style="width:200px; height: 25px;">
</div>
<div class="button">
<div class="signin-btn">SIGN IN</div>
</div>
<p> I want to create <span class="blue">new account</span></p>
<div class="center">
<p>Boeing 777: Dozens grounded after Denver engine failure</p>
<img src="3a.jpg" style="width: 100%;">
</div>
</body>
Try using a flexbox
.top-bar {
background-color: #00008B;
color: white;
display: flex;
justify-content: space-between;
padding: 10px;
}
.top-bar .left {
color: white;
font-weight: bold;
font-size: 20px;
}
.top-bar .right {
color: white;
}
.login-bar {
display: flex;
justify-content: flex-start;
padding: 10px;
}
.login-bar .left {
color: black;
}
.input {
padding-left: 10px;
margin-bottom: 20px;
}
.password-bar {
display: flex;
justify-content: flex-start;
}
.password-bar .left {
color: black;
padding-left: 10px;
}
.input2 {
padding-left: 10px;
padding-top: 10px;
}
.button {
background-color: green;
margin-top: 20px;
margin-left: 10px;
color: white;
width: 60px;
border-radius: 5px;
height: 15px;
font-size: 12px;
text-align: center;
padding: 10px;
}
.blue {
color: #0000FF;
}
.login-flex{
display: flex;
}
<body>
<div class="top-bar">
<div class="left">BITLAB NEWS</div>
<div class="right">About Contacts FAQ Login </div>
</div>
<div class="login-flex">
<div class="login-container">
<div class="login-bar">
<div class="left">EMAIL :</div>
</div>
<div class="input"><input type="text" placeholder="Insert Email" style="width:200px; height: 25px;">
</div>
<div class="password-bar">
<div class="left">PASSWORD :</div>
</div>
<div class="input2"><input type="text" placeholder="Insert Password" style="width:200px; height: 25px;">
</div>
<div class="button">
<div class="signin-btn">SIGN IN</div>
</div>
<p> I want to create <span class="blue">new account</span></p>
</div>
<div class="right-side">
<p>Boeing 777: Dozens grounded after Denver engine failure</p>
<img src="3a.jpg" style="width: 100%;">
</div>
</div>
</body>
I'm not quite sure of the positioning you want, but you can easily obtain your result by using display: flex
You can check some documentation about it here on css-tricks and practice with this quick mini game
flexboxfroggy so that you can obtain the result you want.
.top-bar {
background-color: #00008B;
color: white;
display: flex;
justify-content: space-between;
padding: 10px;
}
.top-bar .left {
color: white;
font-weight: bold;
font-size: 20px;
}
.top-bar .right {
color: white;
}
.login-bar {
display: flex;
width: 90%;
justify-content: space-between;
align-items: flex-start;
flex-direction: row;
padding: 10px;
}
.login-bar .left {
color: black;
}
.input {
padding-left: 10px;
margin-bottom: 20px;
}
.password-bar {
display: flex;
justify-content: flex-start;
}
.password-bar .left {
color: black;
padding-left: 10px;
}
.input2 {
padding-left: 10px;
padding-top: 10px;
}
.button {
background-color: green;
margin-top: 20px;
margin-left: 10px;
color: white;
width: 60px;
border-radius: 5px;
height: 15px;
font-size: 12px;
text-align: center;
padding: 10px;
}
.blue {
color: #0000FF;
}
<div class="top-bar">
<div class="left">BITLAB NEWS</div>
<div class="right">About Contacts FAQ
Login </div>
</div>
<body>
<div class="login-bar">
<div>
<div class="left">EMAIL :</div>
<div class="input"><input type="text" placeholder="Insert Email" style="width:200px; height: 25px;">
</div>
<div class="password-bar">
<div class="left">PASSWORD :</div>
</div>
<div class="input2"><input type="text" placeholder="Insert Password" style="width:200px; height: 25px;">
</div>
<div class="button">
<div class="signin-btn">SIGN IN</div>
</div>
<p> I want to create <span class="blue">new account</span></p>
</div>
<div>
<p>Boeing 777: Dozens grounded after Denver engine failure</p>
<img src="https://nationwideradiojm.com/wp-content/uploads/2021/02/Capture-2.jpg" style="width: 120px;">
</div>
</div>
</body>
My issue:
I'm making somewhat of a Zillow clone. I need the page to not expand beyond 100% of the viewport height however, I'm making a section with the intentions of having the overflow property set to scroll. When I do this, the section expands beyond the viewport height and leaves a large whitespace at the bottom of my page. I can adjust the height to fill up to 100vh however, if I adjust the screen vertically the div with the scroll overflow doesn't adjust to the viewport height. Thanks for any and all help!
Here's a screenshot of my issue:
The circled section is the section that I need the overflow to scroll:
This is my HTML for the entire 'popup' portion:
<div class="home__popup--backdrop">
<div class="home__popup--container">
<div class="home__popup--left">
<div class="home__popup--img--container">
<div class="home__popup--img--main--container">
<img src="./src/img/home-0.jpg" alt="home-0" class="home__popup--img--main">
</div>
<div class="home__popup--img--sub--container">
<img src="./src/img/home-1.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-2.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-3.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-4.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-5.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-0.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-1.jpg" alt="home-0" class="home__popup--img--sub">
<img src="./src/img/home-2.jpg" alt="home-0" class="home__popup--img--sub">
</div>
</div>
</div>
<div class="home__popup--right">
<div class="home__popup--header--container">
<div class="home__popup--logo--container">
<div class="logo__container--home">
<img src="./src/img/logo__house.svg" alt="logo-homes" class="logo logo__homes logo__homes--small">
</div>
<div class="logo__container--txt">
<img src="./src/img/logo__txt.svg" alt="logo-homes" class="logo logo__homes logo__txt--small">
</div>
</div>
<div class="home__popup--social--container">
<div class="home__popup--social">
<img src="./src/img/like.svg" alt="logo like" class="popup__logo logo__like">
<p>Save</p>
</div>
<div class="home__popup--share">
<div class="home__popup--social">
<img src="./src/img/next.svg" alt="logo next" class="popup__logo logo__next">
<p>Share</p>
</div>
</div>
<div class="home__popup--more">
<div class="home__popup--social">
<img src="./src/img/more.svg" alt="logo more" class="popup__logo logo__more">
<p>More</p>
</div>
</div>
</div>
</div>
<div class="home__popup--details--container">
<div class="home__popup--details">
<p class="home__popup--price">$500,000</p>
<p class="home__popup--beds home__popup--details--home">3 <span>bds</span></p>
<p class="home__popup--baths home__popup--details--home">2 <span>ba</span></p>
<p class="home__popup--sqft home__popup--details--home">2,245 <span>sqft</span></p>
</div>
<div class="home__popup--address--container">
<p class="home__popup--address">
4210 sharman rd<span>, </span>
</p>
<p class="home__popup--city">Madison<span>, </span></p>
<p class="home__popup--state">WI</p>
</div>
<div class="home__popup--btn--container">
<button class="btn__agent">Contact Agent</button>
</div>
</div>
<div class="home__popup--overview--container">
<div class="home__popup--overview--container--links">
<img src="./src/img/001-left-arrow.svg" alt="arrow-left" class = 'arrow-small arrow-small--left'>
<div class="home__popup--overview home__popup--overview--active home__popup--overview--container--links--text--container" data-list-section = 0>
<p class="home__popup--overview--text home__popup--overview--container--links--text">Overview</p>
</div>
<div class="home__popup--facts home__popup--overview--container--links--text--container">
<p class="home__popup--facts--text home__popup--overview--container--links--text">Facts and features</p>
</div>
<div class="home__popup--value home__popup--overview--container--links--text--container">
<p class="home__popup--value--text home__popup--overview--container--links--text">Home value</p>
</div>
<div class="home__popup--history home__popup--overview--container--links--text--container" data-list-section = 1>
<p class="home__popup--history--text home__popup--overview--container--links--text">Price and tax history</p>
</div>
<div class="home__popup--monthly home__popup--overview--container--links--text--container">
<p class="home__popup--monthly--text home__popup--overview--container--links--text">Monthly cost</p>
</div>
<div class="home__popup--rental home__popup--overview--container--links--text--container">
<p class="home__popup--rental--text home__popup--overview--container--links--text">Rental Value</p>
</div>
<div class="home__popup--schools home__popup--overview--container--links--text--container" data-list-section = 2>
<p class="home__popup--schools--text home__popup--overview--container--links--text">Nearby schools</p>
</div>
<div class="home__popup--similar home__popup--overview--container--links--text--container">
<p class="home__popup--similar--text home__popup--overview--container--links--text">Similar homes</p>
</div>
<div class="home__popup--neighborhood home__popup--overview--container--links--text--container">
<p class="home__popup--neighborhood--text home__popup--overview--container--links--text">Neighborhood</p>
</div>
<div class="home__popup--homes-for-you home__popup--overview--container--links--text--container">
<p class="home__popup--homes-for-you--text home__popup--overview--container--links--text">Homes for you</p>
</div>
<img src="./src/img/002-right-arrow.svg" alt="arrow-right" class = 'arrow-small arrow-small--right'>
</div>
<div class="home__popup--scroll">
<div class="home__popup--home--detail--container">
<div class="home__popup--map--container">
<div class="test" id = "home__popup--map"></div>
</div>
<div class="home__popup--text--container">
<div class="home__popup--text--stats">
<P class="home__popup--text--header">Overview</P>
<div class="home__popup--text--user-activity">
<p class="home__popup--text--time">Time on Home Finder  <span> --</span></p>
<p class="home__popup--text--views">Views <span>64</span></p>
<p class="home__popup--text--saves">Saves <span>1</span></p>
</div>
<p class="home__popup--text--description">
No showings until 8/22 OH.....
</p>
<p class="home__popup--text--read-more">Read more</p>
</div>
<p class="home__popup--text--open-house--header">Open House</p>
<p class="home__popup--text--open-house--day">Sun, Aug 22</p>
<p class="home__popup--text--open-house--time">12:00 PM - 2:00 PM</p>
<ul class="home__popup--text--agent--container">
<li class="home__popup--text--agent">Kavita Biyani</li>
<li class="home__popup--text--agent">Nik Tantardini</li>
<li class="home__popup--text--agent">First Weber INC</li>
<li class="home__popup--text--agent">Lena Oberwetter</li>
<li class="home__popup--text--agent">Prince Michael</li>
</ul>
<div class="home__popup--overview--text">
</div>
<div class="home--popup--overview--specs">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here's the HTML for the overflowed portion:
<div class="home__popup--scroll">
<div class="home__popup--home--detail--container">
<div class="home__popup--map--container">
<div class="test" id = "home__popup--map"></div>
</div>
<div class="home__popup--text--container">
<div class="home__popup--text--stats">
<P class="home__popup--text--header">Overview</P>
<div class="home__popup--text--user-activity">
<p class="home__popup--text--time">Time on Home Finder  <span> --</span></p>
<p class="home__popup--text--views">Views <span>64</span></p>
<p class="home__popup--text--saves">Saves <span>1</span></p>
</div>
<p class="home__popup--text--description">
No showings until 8/22 OH. Amazing opportunity ...
</p>
<p class="home__popup--text--read-more">Read more</p>
</div>
<p class="home__popup--text--open-house--header">Open House</p>
<p class="home__popup--text--open-house--day">Sun, Aug 22</p>
<p class="home__popup--text--open-house--time">12:00 PM - 2:00 PM</p>
<ul class="home__popup--text--agent--container">
<li class="home__popup--text--agent">Kavita Biyani</li>
<li class="home__popup--text--agent">Nik Tantardini</li>
<li class="home__popup--text--agent">First Weber INC</li>
<li class="home__popup--text--agent">Lena Oberwetter</li>
<li class="home__popup--text--agent">Prince Michael</li>
</ul>
<div class="home__popup--overview--text">
</div>
<div class="home--popup--overview--specs">
</div>
</div>
</div>
Here is the relevant css:
.home__popup {
&--home--detail--container {
}
&--text {
&--description{
font-size: 1.8rem;
font-weight: 300;
color: $color-grey-text;
line-height: 1.3;
}
&--user-activity{
display: flex;
margin-bottom: 2rem;
font-size: 1.4rem;
color: $color-grey-text;
& span{
color: black;
}
}
&--time{
margin-right: 2rem;
border-right: 1px solid $color-grey-medium;
& span{
font-weight: bold;
margin-right: 2rem;
}
}
&--saves{
margin-left: 2rem;
& span{
font-weight: bold;
}
}
&--views{
margin-right: 2rem;
border-right: 1px solid $color-grey-medium;
& span{
font-weight: bold;
margin-right: 2rem;
}
}
&--header {
font-size: 2rem;
font-weight: 700;
letter-spacing: 0.5px;
margin-bottom: 2rem;
}
&--container {
margin-top: 2rem;
display: flex;
flex-direction: column;
margin-left: 1rem;
}
}
&--btn {
&--container {
margin-top: 1rem;
margin-left: 1rem;
display: flex;
justify-content: space-between;
width: 100%;
position: relative;
}
}
&--address {
&--container {
display: flex;
font-weight: 300;
font-size: 1.6rem;
margin-left: 1rem;
margin-top: 1rem;
}
}
&--baths {
margin-left: 0.5rem;
}
&--beds {
margin-left: 2rem;
}
&--price {
margin-top: 3rem;
font-size: 2.5rem;
font-weight: 500;
margin-left: 1rem;
}
&--social {
cursor: pointer;
&--container {
display: flex;
align-items: center;
width: 45%;
justify-content: space-around;
}
}
&--backdrop {
width: 100vw;
height: 100vh;
z-index: 2999;
position: absolute;
top: 0;
left: 0;
backdrop-filter: blur(2px);
background-color: rgba(0, 0, 0, 0.671);
}
&--container {
position: absolute;
top: 0;
left: 50%;
height: 100vh;
width: 65vw;
background-color: white;
transform: translateX(-50%);
z-index: 3000;
backdrop-filter: blur(2px);
display: flex;
flex-direction: row;
}
&--left {
position: relative;
width: 60%;
overflow-y: scroll;
}
&--right {
width: 40%;
position: relative;
}
&--img {
&--main {
height: auto;
object-fit: cover;
width: 100%;
}
&--sub {
height: 25rem;
object-fit: cover;
width: 49.5%;
margin-bottom: 0.4rem;
&--container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
}
}
&--header {
&--container {
display: flex;
justify-content: space-between;
position: relative;
border-bottom: 1px solid #6060607a;
margin-left: 1rem;
margin-right: 1rem;
}
}
&--logo {
&--container {
display: flex;
transform: translateY(1rem);
}
&__homes {
&--small {
height: 6rem;
width: 7rem;
}
}
}
&--details {
display: flex;
align-items: flex-end;
&--container {
display: flex;
flex-direction: column;
position: relative;
}
&--home {
font-size: 1.6rem;
font-weight: 400;
& span {
border-right: 1px solid $color-grey-text;
padding-right: 0.5rem;
font-weight: 300;
}
}
}
&--sqft {
margin-left: 0.5rem;
& span {
border-right: none;
}
}
&--overview {
color: $color-primary;
border-bottom: 2px solid $color-primary;
&--container {
display: flex;
flex-direction: column;
position: relative;
&--links {
display: flex;
overflow-x: scroll;
font-size: 14px;
font-weight: 300;
height: 5rem;
align-items: center;
margin-top: 2rem;
border-top: 1px solid $color-grey-medium;
border-bottom: 1px solid $color-grey-medium;
margin-left: 0.5rem;
margin-right: 0.5rem;
&::-webkit-scrollbar {
display: none;
}
&--text {
margin-left: 1rem;
margin-right: 1rem;
width: max-content;
&--container {
cursor: pointer;
height: 100%;
display: flex;
align-items: center;
transition: .2s all;
&:hover {
color: $color-primary-light;
}
}
}
}
}
}
}
I was having way too many issues out of pure stubbornness of not wanting to change my css however, I finally gave in and refactored the section as a grid. I'm now able to get it to function properly. Here's what it looks like:
And here's the css for the grid-layout:
&--right {
width: 40%;
position: relative;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 5rem 20rem 5rem auto;
}
here's the CSS for the updated div containing the scroll bar:
&--scroll{
grid-column: 1/-1;
grid-row: 4/5;
overflow-y: scroll;
overflow-x: hidden;
}
I am a junior developer and I am trying to create a cart page design for a store.
As you can see in the screenshots, I have completed the majority in desktop design.
The design I have to do: https://gyazo.com/2de152ba832ad4fafffa78d6900c6a67
The design I made: https://gyazo.com/ad387f7c61db2c355765ceaec1f29983
But I cannot create the desired structure in mobile design.
The design I have to do: https://gyazo.com/849bbb190fc312460c16254a322b5d0f
The design I made: https://gyazo.com/5569721f101b34f3530fcbe368fce5fd
How can I code the mobile design as desired?
You can also check it from the link.
https://bee-and-you-development.myshopify.com/cart
HTML
{{ 'cart.scss.css' | asset_url | stylesheet_tag }}
<div class="cart">
<div class="container">
<div class="b_cart">
<div class="cart__items">
<h2 class="fs-20 fw-b tt-u pb-30">Ihr Warenkorb</h2>
<div class="cart__products">
<div class="cart__row cart__header bb--grey fs-14">
<div class="f-2"></div>
<div class="f-5">Artikel</div>
<div class="f-3">Preis</div>
<div class="f-2">Menge</div>
<div class="f-1">Summe</div>
<div class="f-1"></div>
</div>
<div class="cart__product cart__row bb--grey middle">
<div class="cart__productImage"><img style="max-height: 100px; align-content: center;" src="https://cdn.shopify.com/s/files/1/0306/6557/2492/products/13.jpg?v=1578655357" alt=""></div>
<div class="cart__productTitle f-5 fw-b px-1">Gelée Royale Blütenpollen Propolis (Kautabletten)</div>
<div class="cart__productPrices f-3 px-1"><span class="fw-b">€63,91</span> <span class="fw-b td-o fc-g">€63,91 </span><br /> <span class="fw-b fc-g fs-12 ta-r">€536,72/kg</span></div>
<div class="cart__productQty f-2 px-1">Menge</div>
<div class="cart__productPrice f-1 fw-b px-1">€127,91</div>
<div class="cart__productDelete f-1 ta-r">X</div>
</div>
<div class="cart__row bb--grey">
</div>
<div class="cart__row bb--grey">
</div>
</div>
<div>
Weiter einkaufen
</div>
</div>
<div class="cart__summary fw-b">
<h2>Gesamtsumme</h2>
<div class="cart__price">
<div class="cart__row">
<div>Zwischensumme</div>
<div>€172,56</div>
</div>
<div class="cart__row red">
<div>Rabatt</div>
<div>€8,56</div>
</div>
<hr />
<div class="cart__row">
<div class="cart__priceText">Summe</div>
<div class="cart__priceNumber fs-20">€163,91</div>
</div>
<div class="cart__row fs-12 pb-30">
<div>Kostenloser versand ab €34,99</div>
</div>
</div>
<div class="cart__checkboxes">
<div class="cart__agreement pb-10"><input type="checkbox" class="input-checkbox limoniapps-discountninja-checkout-checkbox" value="1" data-message="{{ section.settings.sales_agreement_message}}" >{{ section.settings.sales_agreement_text}}</div>
<div class="cart__marketing">
<div><input type="checkbox" class="input checkbox allow-marketing" /></div>
<div>Bitte halten Sie mich per E-Mail und Text-Nachrichten über Neuigkeiten und exklusive Angebote auf dem Laufenden.</div>
</div>
</div>
<div class="cart__checkout">
<div>
<input class="cart__checkoutButton button fw-b" type="submit" name="checkout"value="{{ section.settings.checkout }}">
</div>
</div>
</div>
</div>
</div>
</div>
SASS
.b_cart {
display: flex;
min-height: 100%;
h2 {
margin: 0;
}
.button {
display: block;
width: 100%;
border: none;
padding: 10px;
cursor: pointer;
text-align: center;
}
.cart__items {
flex: 8;
padding: 30px;
/* debug */
height: 300px;
}
.cart__productImage{
flex: 2;
}
.cart__productTitle{
flex: 5;
}
.cart__header {
font-size: 14px;
font-weight: bold;
}
.cart__summary {
flex: 4;
padding: 30px;
border: 1px solid #ADADAD;
/* debug */
}
.cart__row {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 10px;
}
.cart__checkboxes{
font-size: 12px;
}
.cart__products {
margin: 0;
}
.cart__marketing{
display: flex;
margin-top: 10px;
}
.bb--grey {
border-bottom: 1px solid #adadad;
}
.cart__price {
padding-top: 20px;
}
.cart__productImage{
height: 100px;
}
.cart__checkout{
padding-top: 20px;
}
.cart__checkoutButton{
font-weight: bold;
text-transform: uppercase;
background-color: #ffd500;
border-style: none;
border-radius: 25px;
}
.cancelIcon{
background: url('https://cdn.shopify.com/s/files/1/0306/6557/2492/files/cancel.png?v=1605348792');
height: 40px;
width: 40px;
}
.px-1 {
padding-left: 5px;
padding-right: 5px;
}
.f-1 {
flex: 1;
}
.f-2 {
flex: 2;
}
.f-3 {
flex: 3;
}
.f-4 {
flex: 4;
}
.f-5 {
flex: 5;
}
.fs-12 {
font-size: 12px;
}
.fs-14 {
font-size: 14px;
}
.fs-20 {
font-size: 20px;
}
.fw-b {
font-weight: bold;
}
.fc-g {
color: #adadad;
}
.middle{
margin-top: auto;
margin-bottom: auto;
}
.ta-r {
text-align: right;
}
.ta-l {
text-align: left;
}
.td-o{
text-decoration: line-through;
}
.pb-10 {
padding-bottom: 10px;;
}
.pb-30 {
padding-bottom: 30px;;
}
.tt-u {
text-transform: uppercase;
}
.red {
color: #FF0102;
}
}
#media screen and (max-width: 992px) {
.b_cart {
display: block;
.cart__summary {
margin-top: 25px;
padding: 0px;
border: none;
}
.cart__row {
padding: 0px;
padding-top: 10px;
padding-bottom: 10px;
}
.cart__header{
display: none;
}
.cart__items {
padding: 0px;
}
.cart__productImage{
flex: 4;
}
.cart__productTitle{
flex: 8;
}
}
}
I would appreciate it if you could support, thank you.
I would like to succeed in doing this using flexbox, I have already tried something but without success.
You have to put the title, the price and the input in flex-direction column, right?
Css
.container {
display: flex;
flex-direction: column;
width: 80%;
margin: auto;
}
.details {
flex-grow: 2;
}
.center {
text-align: center;
}
.quantity {
display: flex;
justify-content: center;
}
.quantity button {
width: 20px;
height: 20px;
border: none;
border-radius: 0;
}
.quantity input {
width: 20px;
text-align: center;
border: none;
}
<div class="container">
<h2>Mon Panier</h2>
<div>
<div class="details">
<img src="https://aaaestrie.ca/wp-content/uploads/2017/10/livres.jpg" width="150">
<span>title</span>
<span>39 €</span>
<div class="quantity">
<button class="btn-minus">-</button>
<input type="text" id="quantity" value="1">
<button class="btn-plus">+</button>
</div>
</div>
</div>
</div>
expected template
Is this you are trying to get? It's not quite you showed in the image but it's near.
Let me know if it doesn't work for you.
.container {
display: flex;
flex-direction: column;
width: 80%;
margin: auto;
}
.details {
flex-grow: 2;
}
.center {
text-align: center;
}
.quantity {
display: flex;
justify-content: center;
}
.quantity button {
width: 20px;
height: 20px;
border: none;
border-radius: 0;
}
.quantity input {
width: 20px;
text-align: center;
border: none;
}
.details span:nth-child(2) {
position: absolute;
margin-left: 10px;
font-size: 1.3rem;
}
.details span:nth-child(3) {
display: inline;
float: right;
}
.container {
background-color: lightcoral;
}
.details img {
border: 2px solid gray;
padding: 20px;
}
.inc-dec {
border: 1px solid black;
display: flex;
/* transform: translate(-100%,-100%); */
}
<div class="container">
<h2>Mon Panier</h2>
<div>
<hr>
<div class="details">
<img src="https://aaaestrie.ca/wp-content/uploads/2017/10/livres.jpg" width="150">
<span>title</span>
<span>39 €</span>
<div class="quantity">
<div class="inc-dec">
<button class="btn-minus">-</button>
<input type="text" id="quantity" value="1">
<button class="btn-plus">+</button>
</div>
</div>
</div>
</div>
</div>
you added "Angular" tag to your question so I assume you are using Angular.
if that's the case I highly recommend to use the npm package angular-flex-layout so you don't need to write so much CSS.
import the angular-flex-layout module in your app and watch the magic :)
<div>
<h2>Mon Panier</h2>
<div>
<hr>
<div>
<img src="https://aaaestrie.ca/wp-content/uploads/2017/10/livres.jpg" width="150">
// magic starts here
<div
fxLayout="column"
fxLayoutAlign="center center"
fxLayoutGap=".5rem"
>
<span>title</span>
<span>39 €</span>
<div class="inc-dec">
<button class="btn-minus">-</button>
<input type="text" id="quantity" value="1">
<button class="btn-plus">+</button>
</div>
</div> // magic ends here
</div>
</div>
</div>
hello I want to have a "how" when I go over the picture but the heart is positioned elsewhere. where is the mistake?
and the point I don't understand is why does my card width seem to be overflowing?
Because of the overflow I showed in the picture. When I add a card to the 2nd card. The cards are coming upside down.
.card-video {
width: 305px;
display: flex;
flex-direction: column;
}
.card-pic img {
object-fit: cover;
width: 100%;
height: 100%;
max-width: 305px;
max-height: 170px;
}
.card-info-logo {
position: absolute;
right: 5px;
top: -28px;
}
.card-info-logo img {
width: 55px;
border-radius: 50%;
border: 4px solid #5e4b55;
}
.card-info {
position: relative;
background-color: #292828;
height: 90px;
padding: 7px 10px 10px 10px;
display: flex;
flex-direction: column;
}
.card-info-top {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-info .card-info-category {
color: #546e7a;
font-size: 14px;
}
.card-info .card-info-title {
color: #546e7a;
font-size: 14px;
padding-bottom: 5px;
}
.card-info-bottom {
border-top: solid 1px #44393e;
padding-top: 7px;
display: flex;
align-items: center;
line-height: 1;
justify-content: space-between;
}
.card-info .card-info-bottom .views {
color: #546e7a;
font-size: 12px;
}
.card-info .card-info-bottom .date {
color: #546e7a;
font-size: 12px;
}
.card-pic {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
}
.clip-icon {
position: relative;
}
.clip-icon:hover {
background-color: red;
}
<div class="card-video">
<div class="card-pic">
<a href="">
<img src="https://i.ytimg.com/vi/VeDmG7YovSM/maxresdefault.jpg" alt="">
<div class="clip-icon">
<span class="fa fa-heart"></span>
</div>
</a>
</div>
<div class="card-info mt-1">
<div class="card-info-logo">
<img src="https://yt3.ggpht.com/a/AATXAJxBc7gQx7gKOeJG0uTgpfZVUA1FT_EOxjVjYtI-=s100-c-k-c0xffffffff-no-rj-mo" alt="">
</div>
<div class="card-info-top">
<div class="card-info-category">Video Category</div>
<div class="card-info-title">Video Title</div>
</div>
<div class="card-info-bottom">
<div class="views">312K</div>
<div class="date">16 hour ago</div>
</div>
</div>
</div>
.card-video is having flow direction column.
If you try to put the more card like this it will always show in upside down like a stack. Wrap the entire thing in div and provide the flow-direction: row and flex-wrap : wrap to get desired result.
<style>
.box{
display:flex;
flex-direction:row;
flex-wrap:wrap;
}
.card-video {
width: 305px;
display: flex;
flex-direction: column;
margin:0.5rem;
}
.card-pic img {
object-fit: cover;
width: 100%;
height: 100%;
max-width: 305px;
max-height: 170px;
}
.card-info-logo {
position: absolute;
right: 5px;
top: -28px;
}
.card-info-logo img {
width: 55px;
border-radius: 50%;
border: 4px solid #5e4b55;
}
.card-info {
position: relative;
background-color: #292828;
height: 90px;
padding: 7px 10px 10px 10px;
display: flex;
flex-direction: column;
}
.card-info-top {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-info .card-info-category {
color: #546e7a;
font-size: 14px;
}
.card-info .card-info-title {
color: #546e7a;
font-size: 14px;
padding-bottom: 5px;
}
.card-info-bottom {
border-top: solid 1px #44393e;
padding-top: 7px;
display: flex;
align-items: center;
line-height: 1;
justify-content: space-between;
}
.card-info .card-info-bottom .views {
color: #546e7a;
font-size: 12px;
}
.card-info .card-info-bottom .date {
color: #546e7a;
font-size: 12px;
}
.card-pic {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
}
.clip-icon {
position: relative;
}
.clip-icon:hover {
background-color: red;
}
</style>
<div class="box">
<div class="card-video">
<div class="card-pic">
<a href="">
<img src="https://i.ytimg.com/vi/VeDmG7YovSM/maxresdefault.jpg" alt="">
<div class="clip-icon">
<span class="fa fa-heart"></span>
</div>
</a>
</div>
<div class="card-info mt-1">
<div class="card-info-logo">
<img src="https://yt3.ggpht.com/a/AATXAJxBc7gQx7gKOeJG0uTgpfZVUA1FT_EOxjVjYtI-=s100-c-k-c0xffffffff-no-rj-mo" alt="">
</div>
<div class="card-info-top">
<div class="card-info-category">Video Category</div>
<div class="card-info-title">Video Title</div>
</div>
<div class="card-info-bottom">
<div class="views">312K</div>
<div class="date">16 hour ago</div>
</div>
</div>
</div>
<div class="card-video">
<div class="card-pic">
<a href="">
<img src="https://i.ytimg.com/vi/VeDmG7YovSM/maxresdefault.jpg" alt="">
<div class="clip-icon">
<span class="fa fa-heart"></span>
</div>
</a>
</div>
<div class="card-info mt-1">
<div class="card-info-logo">
<img src="https://yt3.ggpht.com/a/AATXAJxBc7gQx7gKOeJG0uTgpfZVUA1FT_EOxjVjYtI-=s100-c-k-c0xffffffff-no-rj-mo" alt="">
</div>
<div class="card-info-top">
<div class="card-info-category">Video Category</div>
<div class="card-info-title">Video Title</div>
</div>
<div class="card-info-bottom">
<div class="views">312K</div>
<div class="date">16 hour ago</div>
</div>
</div>
</div>
</box>
The flex-direction needs to be set to row, with flex-wrap:wrap as to format correctly.
The .clip-icon can be set to position:absolute if the parent element has position:relative applied.
You can set the clip-icon to display:none and get it to display on picture hover by adding .card-pic:hover .clip-icon: { display:block; }
I have added a snippet below
.box{
display:flex;
flex-direction:row;
flex-wrap:wrap;
}
.card-video {
width: 305px;
display: flex;
flex-direction: column;
margin:0.5rem;
}
.card-pic img {
object-fit: cover;
width: 100%;
height: 100%;
max-width: 305px;
max-height: 170px;
}
.card-info-logo {
position: absolute;
right: 5px;
top: -28px;
}
.card-info-logo img {
width: 55px;
border-radius: 50%;
border: 4px solid #5e4b55;
}
.card-info {
position: relative;
background-color: #292828;
height: 90px;
padding: 7px 10px 10px 10px;
display: flex;
flex-direction: column;
}
.card-info-top {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-info .card-info-category {
color: #546e7a;
font-size: 14px;
}
.card-info .card-info-title {
color: #546e7a;
font-size: 14px;
padding-bottom: 5px;
}
.card-info-bottom {
border-top: solid 1px #44393e;
padding-top: 7px;
display: flex;
align-items: center;
line-height: 1;
justify-content: space-between;
}
.card-info .card-info-bottom .views {
color: #546e7a;
font-size: 12px;
}
.card-info .card-info-bottom .date {
color: #546e7a;
font-size: 12px;
}
.card-pic:hover .clip-icon{
display:block;
}
.card-pic {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
position:relative;
}
.clip-icon a {
position: relative
}
.clip-icon {
position: absolute;
bottom:10px;
left:5px;
width:20px;
height:20px;
background-color:white;
display:none;
}
.clip-icon:hover {
background-color: red;
}
<div class="box">
<div class="card-video">
<div class="card-pic">
<a href="">
<img src="https://i.ytimg.com/vi/VeDmG7YovSM/maxresdefault.jpg" alt="">
<div class="clip-icon">
<span class="fa fa-heart"></span>
</div>
</a>
</div>
<div class="card-info mt-1">
<div class="card-info-logo">
<img src="https://yt3.ggpht.com/a/AATXAJxBc7gQx7gKOeJG0uTgpfZVUA1FT_EOxjVjYtI-=s100-c-k-c0xffffffff-no-rj-mo" alt="">
</div>
<div class="card-info-top">
<div class="card-info-category">Video Category</div>
<div class="card-info-title">Video Title</div>
</div>
<div class="card-info-bottom">
<div class="views">312K</div>
<div class="date">16 hour ago</div>
</div>
</div>
</div>
<div class="card-video">
<div class="card-pic">
<a href="">
<img src="https://i.ytimg.com/vi/VeDmG7YovSM/maxresdefault.jpg" alt="">
<div class="clip-icon">
<span class="fa fa-heart"></span>
</div>
</a>
</div>
<div class="card-info mt-1">
<div class="card-info-logo">
<img src="https://yt3.ggpht.com/a/AATXAJxBc7gQx7gKOeJG0uTgpfZVUA1FT_EOxjVjYtI-=s100-c-k-c0xffffffff-no-rj-mo" alt="">
</div>
<div class="card-info-top">
<div class="card-info-category">Video Category</div>
<div class="card-info-title">Video Title</div>
</div>
<div class="card-info-bottom">
<div class="views">312K</div>
<div class="date">16 hour ago</div>
</div>
</div>
</div>
</box>