Drawing a custom card using flex - html

could someone help me on this, thanks
I'm trying to create the layout identical to figure 2, but I'm not able to ...
How could i do a layout like the figure 2 using flex.
I create a board using flex but the items are not placed in correct way,
and i'm struggling to add a second line.
So far what I've managed to do is the following,
.collection-card {
display: flex;
flex-direction: row;
justify-content: space-between;
flex-grow: 5;
flex-shrink: 5;
min-width: 50em;
max-width: 50em;
margin: 15px !important;
}
.grid-row-container {
display: grid;
grid-template-rows: auto auto;
}
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
// padding: 10px;
}
.grid-item {
//background-color: rgba(255, 255, 255, 0.8);
border: 1px solid rgba(0, 0, 0, 0.8);
// padding-left: 5px;
// padding-right: 5px;
// font-size: 30px;
text-align: center;
}
.my-row {
display: flex;
}
.my-column {
flex: 50%;
}
<Card className='collection-card' interactive={true} onClick={() => history.push(getPath())}>
{/* my-row */}
<div className='tx-inverse tx-bold collection-title'>{name}</div>
<div className='grid-row-container '>
<div className='grid-container'>
<div className='grid-item'>ykykysdfsdfsdafsdfasdfsdf k</div>
<div className='grid-item'>aaaaaa k</div>
<div className='grid-item'>
<div className='collection-card-buttons '>
<button
type='button'
className='btn btn-primary icon-button field-inline card-forcewidth'
onClick={() => {
//setEntityModalOpen(true);
// history.push(`/objects/object-templates/${id}` + window.location.search);
}}
>
view
</button>
</div>
</div>
</div>
<div className='grid-container'>
<div className='grid-item'>aaaaaa k</div>
<div className='grid-item'>aaaaaa k</div>
</div>
</div>
</Card>
and ends up like this:
but what i need is the items placed like this,

In order to share the potential solution, I had to re-write the code to work with plain HTML/CSS. There is no right way to solve the layout issue but I have used flexbox and aligned the elements accordingly to achieve the desired layout. With this example, you should be able to recycle the CSS and add it to your specific project to work. Run the code snippet below and hope it helps!
p {
margin: 0;
padding: 0;
display: inline;
}
.user-container {
max-width: 750px;
border: 1px solid #545454;
border-radius: 15px;
margin: 0 auto;
padding: 2rem;
font-family: Arial, Helvetica, sans-serif;
}
.user-title {
display: block;
font-size: 1rem;
font-weight: 700;
margin: 0;
padding-bottom: 2rem;
}
.user-item {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 1rem;
margin-bottom: 1rem;
border: 1px solid #545454;
border-radius: 15px;
font-size: 12px;
color: #6f6d6d;
}
.btn {
font-weight: 700;
line-height: 1;
font-size: 1rem;
text-transform: none;
padding: 10px 30px;
border: 1px solid #222222;
border-radius: 15px;
text-decoration: none;
color: #fff;
background-color: #222222;
}
.user-item__primary-button {
color: #fff;
background-color: #222222;
}
.user-item__secondary-button {
color: #222222;
background-color: transparent;
}
.w-50 {
width: 50%;
}
.text-ar {
text-align: right;
}
.align-center {
align-self: center;
}
.align-end {
align-self: end;
}
.pb-1 {
padding-bottom: 1rem;
}
.mr-1 {
margin-right: 1rem;
}
<section class="user-container">
<p class="user-title">Users List</p>
<div class="user-item">
<p class="user-item__email w-50 align-center">John Doe (john.doe#gmail.com)
<p>
<div class="w-50 text-ar align-center">
<p class="user-item__role mr-1">Admin</p>
<button class="user-item__primary-button btn">Button</button>
<button class="user-item__secondary-button btn">Button</button>
</div>
<div class="w-50">
<button class="user-item__secondary-button btn">Button</button>
</div>
<p class="user-item__detail w-50 text-ar align-end">Added Dec 01 2021 by Jane Doe</p>
</div>
<div class="user-item">
<p class="user-item__email w-50 align-center">John Doe (john.doe#gmail.com)
<p>
<div class="w-50 text-ar align-center">
<p class="user-item__role mr-1">Admin</p>
<button class="user-item__primary-button btn">Button</button>
<button class="user-item__secondary-button btn">Button</button>
</div>
<div class="w-50">
<button class="user-item__secondary-button btn">Button</button>
</div>
<p class="user-item__detail w-50 text-ar align-end">Added Dec 01 2021 by Jane Doe</p>
</div>
</section>

Related

Resize Image to match Target Image in design system

This is the HTML, the image is contained in the hero-section within the hero container, the image I am working on is the one with class = "tablet". i am trying to replicate the image where the image is offset towARDS THE right side of the screen. I HAVE FOUND IT HARD TO DECIDE ON HOW TO APPROACH THIS, I HAVE TRIED SCALE BUT THEN IT RESIZES VERY SMALL AS THE SCREEN WIDTH REDUCES. PLEASE TAKE A LOOK AT THE CODE AND ANY IDEAS WOULD BE APPRECIATED
<title>Frontend Mentor | Skilled e-learning landing page</title>
</head>
<body>
<nav class="nav">
<span class="nav-item">skilled</span>
Get Started
</nav>
<section class="hero">
<div class="hero-container">
<h1 class="hero-header">Maximize skill, minimize budget</h1>
<p class="hero-txt">
Our modern courses across a range of in-demand skills will give you
the knowledge you need to live the life you want.
</p>
<button class="btn hero-btn">Get Started</button>
</div>
<div class="img-container">
<img alt=" " src="assets/HeroImageMobile.webp" class="mobile" />
<img src="assets\image-hero-tablet#2x.png" alt="" class="tablet" />
</div>
</section>
<main>
<div class="wrapper">
<div class="courses">
<h2 class="courses-header">Check out our most popular courses!</h2>
<div class="course-desc">
<img src="assets\icon-animation.svg" alt="" class="icons" />
<h2 class="course-header">Animation</h2>
<p>
Learn the latest animation techniques to create stunning motion
design and captivate your audience
</p>
<button class="btn main-btn">Get Started</button>
</div>
<div class="course-desc">
<h2 class="course-header">Design</h2>
<img src="assets\icon-Design.svg" alt="" class="icons" />
<p>
Create beautiful, usable interfaces to help shape the future of
how the web looks.
</p>
<button class="btn main-btn">Get Started</button>
</div>
<div class="course-desc">
<img src="assets\icon-photography.svg" alt="" class="icons" />
<h2 class="course-header" 1>Photography</h2>
<p>
Explore critical fundamentals like lighting, composition, and
focus to capture exceptional photos.
</p>
<button class="btn main-btn">Get Started</button>
</div>
<div class="course-desc">
<img src="assets\icon-crypto.svg" alt="" class="icons" />
<h2 class="course-header">Crypto</h2>
<p>
All you need to know to get started investing in crypto. Go from
beginner to advanced with this 54 hour course.
</p>
<button class="btn main-btn">Get Started</button>
</div>
<div class="course-desc">
<img src="assets\icon-business.svg" alt="" class="icons" />
<h2 class="course-header">Business</h2>
<p>
A step-by-step playbook to help you start, scale, and sustain your
business without outside investment.
</p>
<button class="btn main-btn">Get Started</button>
</div>
</div>
</div>
</main>
<footer class="footer">
<span>skilled</span>
Get Started
</footer>
</body>
//CSS
:root{
--Scampi:hsl(234, 25%, 52%);
--Bunting:hsl(233,54%,16%);
--waterloo: hsl(232,10%,56%);
--Violet-Red: hsl(341,92%,62%);
--carnation-pink: hsl(341,100%,83%);
--white:#ffffff;
--roseGrad: linear-gradient(0deg, rgba(240,42,166,1) 0%, rgba(255,111,72,1) 100%);
--DodgerGrad: linear-gradient(180deg, rgba(72,81,255,1) 0%, rgba(240,42,166,1) 100%);
}
html{
background: linear-gradient(180deg, rgba(255,255,255,1) 40%, rgba(240,241,255,1) 100%);
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body{
line-height: 1.2;
font-family: 'Plus Jakarta Sans', sans-serif;;
width: 100%;
margin: 0;
}
body > *{
margin-bottom: 0.9rem;
padding: 0rem 0.7rem;
}
img{
max-width: 100%;
}
a{
text-decoration: none;
color: var(--white);
}
.btn{
padding: 0.9rem 1.5rem;
border-radius: 1.5rem;
border: 0;
display: inline-block;
font-family: 'Plus Jakarta Sans', sans-serif;;
font-size: 1.2rem;
}
.nav-btn{
background-color: var(--Bunting);
}
.hero-btn{
background: var(--roseGrad);
color: var(--white);
}
.main-btn{
color: var(--Violet-Red);
background-color: transparent;
}
.footer-btn{
background: var(--DodgerGrad);
color: white;
}
.nav{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 1.5rem;
}
.nav-item{
font-size: 1.5rem;
font-weight:700 ;
color: var(--Bunting);
}
.hero{
padding: 1rem 0.7rem;
}
.hero-header{
font-size: 2.3rem;
color: var(--Bunting);
}
.hero-txt{
color: var(--waterloo);
font-size: 0.95rem;
line-height: 1.7;
text-align: left;
}
.img-container{
margin-top: 1.5em;
}
.courses{
line-height: 1.7;
}
.courses-header{
color: white;
background: var(--roseGrad);
padding: 2rem;
border-radius: 0.5rem;
}
.main-btn{
padding: 0;
font-weight: 600;
}
.course-desc{
background: var(--white);
position: relative;
margin: 2.8rem 0;
padding: 1rem;
border-radius: 0.5rem;
}
.course-desc > p{
color: var(--waterloo);
}
.icons{
position: absolute;
top: -10%;
}
.footer{
background: var(--Bunting);
color: white;
margin: 0;
margin-top: 5rem;
padding: 2.4rem 0.5rem;
display: flex;
align-items: center;
justify-content: center;
gap: 7rem;
}
.footer > span{
font-size: 1.7rem;
font-weight: bold;
}
.tablet{
display: none;
}
.btn:hover{
opacity: 0.4;
}
.courses, .hero, nav{
width: min(95%, 80vw);
margin: 0 auto;
}
#media(min-width:700px) {
nav{
padding: 1.4rem;
}
.hero{
display: flex;
gap: 1.5rem;
padding:0 1.4rem;
margin-top: 1.5rem;
position: relative;
}
.hero-container{
margin-top: 10.5rem;
height: 50%;
}
.mobile{
display: none;
}
.hero-container{
flex-grow: 2;
}
///This is the container for the image
.img-container{
transform: scale(1.5);
position: relative;
left: 10rem;
/// THIS IS THE IMAGE DECLARATION
}
.tablet{
display: inline-block;
transform: scale(4rem);
}
main{
margin-top: 3.5rem;
}
.courses{
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.courses, .hero, nav{
width: 80%;
max-width:950PX;
margin: 0 auto;
}
.course-desc{
padding:min(1.4rem,1.7rem) ;
display: flex;
flex-direction: column;
/* width: 400px; */
font-size: min(1rem, 2rem);
}
.courses-header{
margin-Bottom:3rem;
}
.course-desc > p{
height: 30%;
margin: 0;
margin-bottom: 2.5rem;
}
.main-btn{
text-align: left;
}
.footer{
justify-content: space-between;
}
.footer > *{
margin: 0 1rem;
}
}
#media(min-width:1400px){
.courses{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: repeat(2,400px);
gap: 1rem;
padding: 1.5rem;
}
main, .hero, nav {
width: 95%;
margin: 0 auto;
}
.course-desc{
padding:1.5rem 1rem
}
.main-btn{
margin-bottom: 2.5rem;
}
.hero, nav{
width: 75%;
}
.courses{
width: 2000px
}
}
You can try having both the images in the same parent, give position relative to parent and then position absolute to the image which you want on the right side. And then write css for that image to have bottom and left properties to shift it towards right and top. Note that this common parent should not contain anything else except these two images.

Stop element's position being influenced by other elements' content

I am currently working on a Forum website, and can't figure out how to place elements that won't be influenced by other elements' content.
For example, if I change the element content text, the other elements that are next to it will change position.
Example:
HTML and CSS from the first image:
.staff-show {
float: right;
margin-right: 10em;
margin-top: 10em;
}
.staff-show .title-staff {
font-family: Poppins-SemiBold, FontAwesome;
display: flex;
align-items: center;
justify-content: center;
}
.staff-show .title-staff i {
margin-right: 1em;
}
.staff-show .title-staff h2 {
right: 5%;
}
.staff-show .staff-list h3,
p {
margin: 0.1em;
padding: 0.1em;
}
.staff-show .staff-list .icon-border {
border: 2px solid #212e38;
border-radius: 10px;
width: 4em;
height: 4em;
display: inline-block;
}
.staff-show .staff-list i {
padding: 1.3em 0.9em;
text-align: center;
}
.staff-show .staff-list ul li {
margin: 1.2em;
}
.staff-show .staff-list .staff-info {
float: right;
margin-left: 1.5em;
}
<div class="staff-show">
<div class="staff-list">
<ul>
<li>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>Johnny Games</h3>
<p>System Admin</p>
</div>
</li>
<li>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>John Lenon</h3>
<p>Service Founder</p>
</div>
</li>
</ul>
</div>
</div>
Second image HTML and CSS:
.forum-list button {
border: 2px solid #212e38;
border-radius: 20px;
padding: 10px 40px;
width: 77em;
height: 8.5em;
font-family: Poppins-SemiBold, FontAwesome;
color: white;
margin-right: 1em;
margin-bottom: 1.5em;
display: grid;
}
.forum-list-border {
border: 2px solid #172129;
border-radius: 20px;
width: 5.7em;
height: 5.7em;
margin-top: 0.3em;
}
.forum-list i {
margin-top: 1.5em;
width: 100%;
}
.forum-list-header {
display: flex;
align-items: center;
}
.forum-list h2 {
margin-left: 2em;
}
.forum-list .forum-list.btn {
margin-bottom: 2em;
}
.forum-list-info {
grid-column-start: 2;
grid-column-end: 3;
}
.forum-list-info-numbers {
display: flex;
align-items: center;
}
.forum-list-info-text {
display: flex;
align-items: center;
}
.forum-list-info-numbers h3 {
margin-right: 6.3em;
}
.forum-list-info-text p {
margin-right: 5em;
}
<div class="forum-container">
<div class="forum-list-container">
<div class="forum-list">
<button class="forum-list-btn">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Tech, Informatique et autres</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers"><h3>5.1k</h3><h3>50.3k</h3></div>
<div class="forum-list-info-text"><p>Posts</p><p>Messages</p></div>
</div>
</button>
</div>
</div>
</div>
Sorry for this long code, I just want to make this as explicit as possible, so it's easier to solve.
You can use the display: flex property to achieve both results. I have added another wrapper div for the first image and added a new class on button for the second one.
.staff-show {
float: right;
margin-right: 10em;
margin-top: 10em;
}
.staff-show .title-staff {
font-family: Poppins-SemiBold, FontAwesome;
display: flex;
align-items: center;
justify-content: center;
}
.staff-show .title-staff i {
margin-right: 1em;
}
.staff-show .title-staff h2 {
right: 5%;
}
.staff-show .staff-list h3,
p {
margin: 0.1em;
padding: 0.1em;
}
.staff-show .staff-list .icon-border {
border: 2px solid #212e38;
border-radius: 10px;
width: 4em;
height: 4em;
display: inline-block;
}
.staff-show .staff-list i {
padding: 1.3em 0.9em;
text-align: center;
}
.staff-show .staff-list ul li {
margin: 1.2em;
}
.staff-show .staff-list .staff-info {
float: right;
margin-left: 1.5em;
}
.another-div {
display: flex;
}
<div class="staff-show">
<div class="staff-list">
<ul>
<li>
<div class='another-div'>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>Johnny Games</h3>
<p>System Admin</p>
</div>
</div>
</li>
<li>
<div class='another-div'>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>John Lenon</h3>
<p>Service Founder</p>
</div>
</div>
</li>
</ul>
</div>
</div>
.forum-list button {
border: 2px solid #212e38;
border-radius: 20px;
padding: 10px 40px;
width: 77em;
height: 8.5em;
font-family: Poppins-SemiBold, FontAwesome;
color: white;
margin-right: 1em;
margin-bottom: 1.5em;
display: grid;
}
.forum-list-border {
border: 2px solid #172129;
border-radius: 20px;
width: 5.7em;
height: 5.7em;
margin-top: 0.3em;
}
.forum-list i {
margin-top: 1.5em;
width: 100%;
}
.forum-list-header {
display: flex;
align-items: center;
}
.forum-list h2 {
margin-left: 2em;
}
.forum-list .forum-list.btn {
margin-bottom: 2em;
}
.forum-list-info {
grid-column-start: 2;
grid-column-end: 3;
}
.forum-list-info-numbers {
display: flex;
align-items: center;
}
.forum-list-info-text {
display: flex;
align-items: center;
}
.forum-list-info-numbers h3 {
margin-right: 6.3em;
}
.forum-list-info-text p {
margin-right: 5em;
}
.d-flex-between {
display: flex !important;
justify-content: space-between;
}
<div class="forum-container">
<div class="forum-list-container">
<div class="forum-list">
<button class="forum-list-btn d-flex-between">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Tech, Informatique et autres</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers">
<h3>5.1k</h3>
<h3>50.3k</h3>
</div>
<div class="forum-list-info-text">
<p>Posts</p>
<p>Messages</p>
</div>
</div>
</button>
<button class="forum-list-btn d-flex-between">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Account Boost</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers">
<h3>5.1k</h3>
<h3>50.3k</h3>
</div>
<div class="forum-list-info-text">
<p>Posts</p>
<p>Messages</p>
</div>
</div>
</button>
</div>
</div>
</div>
Your first example does this because the .staff-show .staff-list .staff-info rule is set to float: right. So, when the content in div.staff-info gets smaller, the right side of the div will remain flush with the right side of its container.
Assuming you won't have enough content to force it to wrap, you could simply do the following to keep it left-aligned with the bordered box:
.staff-show .staff-list .staff-info {
display: inline-block;
vertical-align: top;
margin-left: 1.5em;
}
However, I would suggest using a grid layout or a similar technique so that it's less likely to break if your content size or container size changes.
In your second example, just add justify-content: space-between to the .forum-list button rule.
You need to differentiate the class names for example in the first image you have both classes named as staff-info, meaning if you style the staff-info class both divs will change simultaneously.

HTML/CSS How do I make all the element of each box aligned?

how i want it to look like
how it looks right now
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
padding-bottom: 5%;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 12px 34px;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: relative;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<img src="images/Home/Layer 2-2.svg">
<p>Interact with a TIL timeline showing key moments and events over the years</p>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Progress.svg">
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Report_icons-02 1.svg">
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>
I want to make the image of each box aligned with each other, same with the text and the button, like it is presented in the image. Yet everything would follow right after the image, the text ends. I also want to uniform the size of the image, without messing up the proportion, but I don't know how to do so.
Simply adding the below styles to ".til-col" class will achieve the expected result
display: flex;
text-align: center;
Maybe something like this?
P.S. I don't think CSS have something to let you horzionally align several child elements from different blocks.
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
display:flex;
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
padding-bottom: 5%;
}
.til-col > p{
padding-bottom:40px;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 12px 34px;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: absolute;
bottom:20px;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<img src="images/Home/Layer 2-2.svg">
<p>Interact with a TIL timeline showing key moments and events over the years</p>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Progress.svg">
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<img src="images/Home/Report_icons-02 1.svg">
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>
You can follow below code for solution
.row2 {
display: flex;
justify-content: space-evenly;
align-items: stretch;
}
.til-col {
flex-basis: 32%;
border: 7px solid #c9c9c9;
border-radius: 30px;
margin: 10px;
position: relative;
overflow: hidden;
padding: 40px;
box-shadow: 5px 5px 20px rgba(92, 91, 91, 0.2);
flex-direction: column;
align-items: center;
display: flex;
justify-content: space-between;
text-align: center;
}
.til-col img {
width: 50%;
border-radius: 10px;
}
.icon{
display: flex;
align-items: center;
justify-content: center;
height: 150px;
margin-bottom: 30px;
}
.button {
display: inline-block;
text-decoration: none;
color: #fff;
margin: 34px 0 0 0;
border-radius: 10px;
font-size: 13px;
padding: 0 20px;
background: #012a5d;
position: relative;
cursor: pointer;
}
<div class="row2">
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://dynamic.brandcrowd.com/asset/logo/2a056b05-ac9b-404f-a619-eba59f92ef48/logo-search-grid-1x?v=637631474641000000"></div>
<p>Interact with a TIL timeline showing key moments and events over the years</p>
</div>
<a href="classroom.html" class="button">
<h3>TIL Story</h3>
</a>
</div>
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://cdn-icons-png.flaticon.com/512/109/109733.png"></div>
<p>Discover projects and initiatives that have launched out of TIL to support innovation in learning spaces</p>
</div>
<a href="classroom.html" class="button">
<h3>Projects</h3>
</a>
</div>
<div class="til-col">
<div class="til-col-head">
<div class="icon"><img src="https://miro.medium.com/max/1268/0*2pi-PJAAVse41Ovk.png"></div>
<p>See the transformation of classroom spaces and follow progress over stages of the redesign process</p>
</div>
<a href="classroom.html" class="button">
<h3>Classroom Redesign</h3>
</a>
</div>
</div>

Making the cart design mobile compatible as desired

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.

HTML button not styling correctly

I am attempting to recreate buttons that I have already created for my desktop site by using the same css styling on the mobile buttons. i have tried deleting the css one line at time and it doesn't seem to be the css (after all the same css works for the desktop buttons.
The problem: I want the buttons to be completely styled but instead it is leaving the stock button and adding the style as a border
#clients-title {
background: #f4f4f4;
padding: 1rem 0;
}
#clients-grid {
display: grid;
background: #f4f4f4;
text-align: center;
padding: 1rem 0;
margin: 0 10%;
grid-template-columns: 33.3% 33.3% 33.3%;
}
#clients-btn-grid {
display: grid;
background: #f4f4f4;
text-align: center;
padding: 1rem 0;
margin: 0 10%;
grid-template-columns: 33.3% 33.3% 33.3%;
}
#clients-btn-grid .cr-btn {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-top: -40px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
#clients-btn-grid .cr-btn:hover {
cursor: pointer;
background-color: #333;
}
#media(max-width: 800px) {
#clients-btn-grid {
display: none;
}
}
.mobile-grid {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-top: -40px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
#media(min-width: 800px) {
.mobile-grid {
display: none;
}
}
<section id="clients-title">
<div class="grid-items">
<h2 class="m-heading text-center">
<span id="client-r" class="text-primary">Client</span> Resources
</h2>
</div>
<div id="clients-grid">
<div class="grid-items">
<h2>
TD Ameritrade Access
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://www.advisorclient.com/login'">LOGIN</button>
</div>
</div>
<div class="grid-items">
<h2>
American Equity
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://client.american-equity.com/Login/login?ReturnUrl=%2F'">LOGIN</button>
</div>
</div>
<div class="grid-items">
<h2>
IRS-Where's My Refund?
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://sa.www4.irs.gov/irfof/lang/en/irfofgetstatus.jsp'">LOGIN</button>
</div>
</div>
</div>
<div id="clients-btn-grid">
<div class="grid-items">
<button onclick="location.href='https://www.advisorclient.com/login'"class="cr-btn">LOGIN</button>
</div>
<div class="grid-items">
<button onclick="location.href='https://client.american-equity.com/Login/login?ReturnUrl=%2F'"class="cr-btn">LOGIN</button>
</div>
<div class="grid-items">
<button onclick="location.href='https://sa.www4.irs.gov/irfof/lang/en/irfofgetstatus.jsp'"class="cr-btn">LOGIN</button>
</div>
</div>
</section>
If you click full screen after running the code you can see the buttons displaying correct.
SOLUTION: Instead of targeting the div that the button is in I just needed target the parent div with buttons e.g
#clients-grid button {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-top: -40px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
You did not style buttons inside #clients-grid. I also recommend you to use the same button tags for desktop and mobile view, because it would be a desaster if you have to change a link for example.
Just delete the .mobile-grid div around the button tags and style the buttons like in the desktop view.
added
button {
background-color: #4C9FCF;
color: white;
border: none;
}
button:focus{
outline:none}
#clients-title {
background: #f4f4f4;
padding: 1rem 0;
}
#clients-grid {
display: grid;
background: #f4f4f4;
text-align: center;
padding: 1rem 0;
margin: 0 10%;
grid-template-columns: 33.3% 33.3% 33.3%;
}
#clients-btn-grid {
display: grid;
background: #f4f4f4;
text-align: center;
padding: 1rem 0;
margin: 0 10%;
grid-template-columns: 33.3% 33.3% 33.3%;
}
#clients-btn-grid .cr-btn {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-top: -40px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
#clients-btn-grid .cr-btn:hover {
cursor: pointer;
background-color: #333;
}
#media(max-width: 800px) {
#clients-btn-grid {
display: none;
}
}
.mobile-grid {
background-color: #4C9FCF;
margin-left: auto;
margin-right: auto;
margin-top: -40px;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
button {
background-color: #4C9FCF;
color: white;
border: navajowhite;
}
button:focus{
outline:none}
#media(min-width: 800px) {
.mobile-grid {
display: none;
}
}
<section id="clients-title">
<div class="grid-items">
<h2 class="m-heading text-center">
<span id="client-r" class="text-primary">Client</span> Resources
</h2>
</div>
<div id="clients-grid">
<div class="grid-items">
<h2>
TD Ameritrade Access
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://www.advisorclient.com/login'">LOGIN</button>
</div>
</div>
<div class="grid-items">
<h2>
American Equity
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://client.american-equity.com/Login/login?ReturnUrl=%2F'">LOGIN</button>
</div>
</div>
<div class="grid-items">
<h2>
IRS-Where's My Refund?
<p></p>
</h2>
<div class="mobile-grid">
<button onclick="location.href='https://sa.www4.irs.gov/irfof/lang/en/irfofgetstatus.jsp'">LOGIN</button>
</div>
</div>
</div>
<div id="clients-btn-grid">
<div class="grid-items">
<button onclick="location.href='https://www.advisorclient.com/login'"class="cr-btn">LOGIN</button>
</div>
<div class="grid-items">
<button onclick="location.href='https://client.american-equity.com/Login/login?ReturnUrl=%2F'"class="cr-btn">LOGIN</button>
</div>
<div class="grid-items">
<button onclick="location.href='https://sa.www4.irs.gov/irfof/lang/en/irfofgetstatus.jsp'"class="cr-btn">LOGIN</button>
</div>
</div>
</section>