I am still learning CSS, html and concepts of responsive design. Can someone can please help me to stack these boxes as rows in responsive instead of columns. Please see the code below.
.row {
display: flex;
/* equal height of the children */
}
.col1 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
margin: 0 40px 0 0;
padding: 0 0 10px 0;
}
.col2 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
padding: 0 0 10px 0;
}
.card-header {
background: rgba(242, 242, 242, 1);
text-align: left;
font-size: 12px;
font-weight: 600;
padding: 31px 10px 31px 15px;
}
.card-header-bg {
height: 7px;
}
.card-container {
padding: 2px 14px;
}
.blue-button,
a.blue-button {
background-color: #026fc2;
border-radius: 99rem;
box-shadow: inset 0 0 0 1px #454545;
color: #fff;
text-decoration: none;
font-weight: 600;
padding: 0.5rem 1rem;
text-align: center;
display: inline-block;
}
<div class="row">
<div class="col1">
<div class="card-header-bg" style=" background-color: rgba(255, 181, 119, 1);"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>Test Example</p>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
<p>Minor updates.</p>
<ul>
<li>test</li>
<li>Test</li>
</ul>
<p>Go Here</p>
</div>
</div>
<div class="col2">
<div class="card-header-bg" style=" background-color: #7ECEFD;"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>test123/p>
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
<p>test test test.</p>
<ul>
<li>Learn about testing</li>
</ul>
<p>Second Test</p>
</div>
</div>
</div>
Remove margin on col1 and use flex-direction: column; on your row.
.row {
display: flex;
flex-direction: row;
/* equal height of the children */
}
#media only screen and (max-width: 600px) {
.row {
flex-direction: column;
}
.col1 {
margin: 0px !important;
}
}
.col1 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
margin: 0 40px 0 0;
padding: 0 0 10px 0;
}
.col2 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
padding: 0 0 10px 0;
}
.card-header {
background: rgba(242, 242, 242, 1);
text-align: left;
font-size: 12px;
font-weight: 600;
padding: 31px 10px 31px 15px;
}
.card-header-bg {
height: 7px;
}
.card-container {
padding: 2px 14px;
}
.blue-button,
a.blue-button {
background-color: #026fc2;
border-radius: 99rem;
box-shadow: inset 0 0 0 1px #454545;
color: #fff;
text-decoration: none;
font-weight: 600;
padding: 0.5rem 1rem;
text-align: center;
display: inline-block;
}
<div class="row">
<div class="col1">
<div class="card-header-bg" style=" background-color: rgba(255, 181, 119, 1);"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>Test Example</p>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
<p>Minor updates.</p>
<ul>
<li>test</li>
<li>Test</li>
</ul>
<p>Go Here</p>
</div>
</div>
<div class="col2">
<div class="card-header-bg" style=" background-color: #7ECEFD;"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>test123</p>
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
<p>test test test.</p>
<ul>
<li>Learn about testing</li>
</ul>
<p>Second Test</p>
</div>
</div>
</div>
Edit ~ Image of flex-direction: row; with gap. Resembles margin you had set initially.
Edit ~ added media-query to have div's stack when resizing. Also, put back in your margin for the row/desktop view on IE, but removed the margin once the div's stack.
#media only screen and (max-width: 600px) {
.row {
flex-direction: column;
}
.col1 {
margin: 0px !important;
}
}
Related
I’m currently working on a project from Frontend mentor, while developing the mobile version an issue arose where the main section is overflowing onto the footer section.
:root {
--DarkViolet: hsl(256, 26%, 20%);
--Grayish-Blue: hsl(216, 30%, 68%);
--VeryLight-Gray: hsl(0, 0%, 98%);
--Dark-Grayish-Violet: hsl(273, 4%, 51%);
--Very-Dark-Violet: hsl(270, 9%, 17%);
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.hide {
display: none;
}
.content-container {
width: 100%;
padding: 10px 0;
margin: auto;
}
main {
border: 10px dashed red;
display: flex;
flex-direction: column;
}
.flex {
display: flex;
}
.purple {
background-color: var(--DarkViolet);
color: #fff;
}
button {
background-color: var(--DarkViolet);
color: #fff;
border: 2px solid;
padding: 5px 20px;
font-size: .8em;
width: 200px;
}
#media only screen and (min-width: 214px) {
* {
overflow-x: hidden;
}
.content-container {
width: 90%;
}
header {
position: fixed;
background-color: white;
width: 100%;
z-index: 15;
}
header .flex {
flex-direction: row;
justify-content: space-between;
margin-top: 10px;
}
header>* {
padding: 20px;
justify-content: space-between;
}
.menu {
position: fixed;
top: 0;
right: 0;
margin-top: 60px;
background-color: var(--Very-Dark-Violet);
padding: 50px 0;
text-align: center;
height: 100%;
width: 100%;
transform: translateY(-800px);
opacity: 0;
transition: all 0.5s ease-in-out;
}
.menu img {
width: inherit;
position: absolute;
right: 0;
bottom: 0;
}
.menu.open {
overflow: hidden;
opacity: 1;
font-size: 1.3em;
transform: translateY(0px);
transition: all 0.5s ease-in-out;
background-image: url(images/bg-pattern-mobile-nav.svg);
background-position: bottom;
background-repeat: no-repeat;
}
.menu .navLinks {
border: 1px solid gray;
display: block;
list-style: none;
background-color: inherit;
color: #000;
}
.menu .navLinks li {
color: white;
margin: auto;
margin-bottom: 40px;
margin-left: 0;
width: 100%;
}
.menu .navLinks li a {
color: white;
text-decoration: none;
font-size: 1.2em;
text-transform: uppercase;
padding: 0;
margin: 0;
}
.menu .navLinks button {
width: 80%;
font-size: 1.2em;
text-transform: uppercase;
}
main {
transform: translateY(70px);
}
.mobile-intro-img {
width: 100%;
object-fit: fill;
margin-bottom: 0;
}
.purple-big-banner {
border: 3px solid red;
margin: 0;
background-color: var( --Very-Dark-Violet);
color: white;
position: relative;
overflow: hidden;
background-image: url(images/bg-pattern-intro-left-mobile.svg);
background-repeat: no-repeat;
}
.purple-big-banner .mobile-intro-img-left {
position: absolute;
top: 0;
left: 0;
z-index: 100;
}
.purple-big-banner .mobile-intro-img-right {
position: absolute;
bottom: -50%;
z-index: 100;
right: 0;
}
.purple-big-banner .content-container {
border: 3px dashed white;
}
.purple-big-banner .content {
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
gap: 2em;
margin: auto;
padding-top: 60px;
padding-bottom: 60px;
border: 1px solid red;
}
.purple-big-banner button {
margin: auto;
width: 60%;
}
.content-container>.mobile-intro-img-right-continued {
position: absolute;
top: 35%;
right: 0;
}
h1 {
overflow: hidden;
text-align: center;
font-size: 2em;
line-height: .85;
font-family: 'DM Serif Display', serif;
}
.purple-big-banner p {
line-height: 1.4em;
margin: 10px 0;
font-size: 1.1em;
}
hr {
width: 100px;
margin: auto;
margin-top: 40px;
margin-bottom: 20px;
}
.flex {
flex-direction: column;
margin-top: 40px;
align-items: center;
justify-content: center;
}
.box {
margin-bottom: 40px;
border: 1px solid rgb(31, 31, 31);
}
.box img {
padding: auto;
border: 1px solid red;
}
.box>* {
margin-bottom: 20px;
text-align: center;
}
.box p {
color: var(--Grayish-Blue);
}
.small-banner {
border: 5px solid red;
text-align: center;
background-image: url(images/bg-pattern-how-we-work-mobile.svg);
background-color: var( --Very-Dark-Violet);
color: white;
}
.small-banner .content {
display: flex;
flex-direction: column;
gap: 20px;
padding: 40px 0;
}
.small-banner button {
margin: auto;
width: 65%;
}
footer {
background-color: var(--VeryLight-Gray);
background-image: url(images/bg-pattern-footer-mobile.svg);
background-repeat: no-repeat;
border: 3px solid blue;
}
}
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&display=swap" rel="stylesheet">
<header>
<div class="content-container flex">
<img src="images/logo.svg" alt="" srcset="">
<nav class="menu">
<ul class="navLinks">
<li><a class="menuItem" href="#">How we work</a></li>
<li><a class="menuItem" href="#">Blog</a></li>
<li><a class="menuItem" href="#">Account</a></li>
<li><button class="menuItem">View plans</button></li>
</ul>
</nav>
<div class="hamburger ">
<img class="menuIcon" src="images/icon-hamburger.svg " alt="">
<img class="closeIcon hide" src="images/icon-close.svg" alt="">
</div>
</div>
</header>
<main class="flex-main">
<img src="images/image-intro-mobile.jpg" alt="" class="mobile-intro-img-left">
<div class="purple-big-banner">
<div class="content-container">
<div class="content">
<hr class="hide">
<div>
<h1> Humanizing your insurance.</h1>
</div>
<div>
<p>
Get your life insurance coverage easier and faster. We blend our expertise blank and technology to help you find the plan that’s right for you. Ensure you and your loved ones are protected.
</p>
</div>
<div>
<button class="upper">View plans</button>
</div>
</div>
</div>
<img src="images/bg-pattern-intro-right-desktop.svg" class="pattern-right hide" alt="" srcset="">
<img src="images/bg-pattern-intro-left-desktop.svg" class="pattern-left hide" alt="" srcset="">
</div>
<div class="content-container">
<img src="images/bg-pattern-intro-right-mobile.svg" alt="" class="mobile-intro-img-right-continued">
<div class="content">
<hr>
<h1>We’re different</h1>
<div class="flex">
<div class="box">
<div>
<img src="images/icon-snappy-process.svg" alt="">
</div>
<h2>Snappy Process</h2>
<p> Our application process can be completed in minutes, not hours. Don’t get stuck filling in tedious forms.</p>
</div>
<div class="box">
<div>
<img src="images/icon-affordable-prices.svg" alt="">
</div>
<h2> Affordable Prices</h2>
<p> We don’t want you worrying about high monthly costs. Our prices may be low, but we still offer the best coverage possible.</p>
</div>
<div class="box">
<div>
<img src="images/icon-people-first.svg" alt="">
</div>
<h2>People First</h2>
<p> Our plans aren’t full of conditions and clauses to prevent payouts. We make sure you’re covered when you need it.</p>
</div>
</div>
</div>
</div>
<div class="content-container small-banner">
<div class="content">
<div>
<h2>Find out more <br> about how we work</h2>
</div>
<button class="upper">How we work</button>
</div>
</div>
</main>
<footer>
<div class="footer-top">
<div class="content-container flex">
<div class="logo">
<img src="images/logo.svg" alt="" srcset="">
</div>
<div class="flex social">
<ion-icon name="logo-facebook"></ion-icon>
<ion-icon name="logo-twitter"></ion-icon>
<ion-icon name="logo-pinterest"></ion-icon>
<ion-icon name="logo-instagram"></ion-icon>
</div>
</div>
<hr class="content-container">
</div>
<div class="footer-bottom content-container flex">
<div>
<p class="title upper">Our company</p>
<ul>
<li>How we work</li>
<li>Why Insure?</li>
<li>View plans</li>
<li>Reviews</li>
</ul>
</div>
<div>
<p class="title upper">Help me</p>
<ul>
<li>FAQ</li>
<li>Terms of use</li>
<li>Privacy policy</li>
<li>Cookies</li>
</ul>
</div>
<div>
<p class="title upper">Contact</p>
<ul>
<li>Sales</li>
<li>Support</li>
<li>Live chat</li>
</ul>
</div>
<div>
<p class="title upper">Others</p>
<ul>
<li>Careers</li>
<li>Press</li>
<li>Licenses</li>
</ul>
</div>
<div></div>
</div>
<div class="attribution">
Challenge by Frontend Mentor. Coded by Your Name Here.
</div>
</footer>
<script type="module" src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.js"></script>
It seems like this is probably your issue:
main {
transform: translateY(70px);
}
I am still learning CSS and HTML. So please excuse me if this is a silly question.
Please see my code below. I need help with aligning the blue buttons on both the cards. It should be on the bottom of the cards (aligned similarly) regardless of content size.
Please advise.
.row {
display: flex;
/* equal height of the children */
}
.col1 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
margin: 0 40px 0 0;
padding: 0 0 10px 0;
}
.col2 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
padding: 0 0 10px 0;
}
.card-header {
background: rgba(242, 242, 242, 1);
text-align: left;
font-size: 12px;
font-weight: 600;
padding: 31px 10px 31px 15px;
}
.card-header-bg {
height: 7px;
}
.card-container {
padding: 2px 14px;
}
.blue-button,
a.blue-button {
background-color: #026fc2;
border-radius: 99rem;
box-shadow: inset 0 0 0 1px #454545;
color: #fff;
text-decoration: none;
font-weight: 600;
padding: 0.5rem 1rem;
text-align: center;
display: inline-block;
}
<div class="row">
<div class="col1">
<div class="card-header-bg" style=" background-color: rgba(255, 181, 119, 1);"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>Test Example</p>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
<p>Minor updates.</p>
<ul>
<li>test</li>
<li>Test</li>
</ul>
<p>Go Here</p>
</div>
</div>
<div class="col2">
<div class="card-header-bg" style=" background-color: #7ECEFD;"></div>
<div class="card-header">Header</div>
<div class="card-container">
<p>test123/p>
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
<p>test test test.</p>
<ul>
<li>Learn about testing</li>
</ul>
<p>Second Test</p>
</div>
</div>
</div>
Not a silly question. They seem unaligned because there are more li's on the left side. Buttons are positioned statically by default, so if there is more content, it will be pushed down. You'll notice if you add more li's on the right side, the button will be pushed down and seem aligned. You may find nesting the buttons in their own divs will give you more control.
However, you can easily resolve this with your current structure by adding <br> or the line-break element on the button that is positioned higher. See below.
.row {
display: flex;
/* equal height of the children */
}
.col1 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
margin: 0 40px 0 0;
padding: 0 0 10px 0;
}
.col2 {
flex: 1;
/* additionally, equal width */
border: 1px solid #dadada;
padding: 0 0 10px 0;
}
.card-header {
background: rgba(242, 242, 242, 1);
text-align: left;
font-size: 12px;
font-weight: 600;
padding: 31px 10px 31px 15px;
}
.card-header-bg {
height: 7px;
}
.card-container {
padding: 2px 14px;
display: flex;
flex-direction: column;
justify-content: center;
}
.blue-button,
a.blue-button {
background-color: #026fc2;
border-radius: 99rem;
box-shadow: inset 0 0 0 1px #454545;
color: #fff;
text-decoration: none;
font-weight: 600;
padding: 0.5rem 1rem;
text-align: center;
display: inline-block;
}
.btn-primary {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 10px;
}
.card-container>div {
height: 210px;
}
<div class="row">
<div class="col1">
<div class="card-header-bg" style=" background-color: rgba(255, 181, 119, 1);"></div>
<div class="card-header">Header</div>
<div class="card-container">
<div>
<p>Test Example</p>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
<p>Minor updates.</p>
<ul>
<li>test</li>
<li>Test</li>
</ul>
</div>
</div>
<div class="btn-primary">
Go Here
</div>
</div>
<div class="col2">
<div class="card-header-bg" style=" background-color: #7ECEFD;"></div>
<div class="card-header">Header</div>
<div class="card-container">
<div>
<p>test123</p>
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
<p>test test test.</p>
<ul>
<li>Learn about testing</li>
</ul>
</div>
</div>
<div class="btn-primary">
Second Test
</div>
</div>
Largest rendered height at default ~ makes height for both divs.
This question already has answers here:
Why are my flex items not wrapping?
(2 answers)
Closed 1 year ago.
I was creating a simple flexbox pricing page for my assignment and I ended up completing it. The problem is that the pricing cards do not wrap to the next row when the screen size is reduced i have set flex-wrap to wrap but still no luck. I searched this problem up and some results said that setting flex-container max-width to 100% would help, but it didn't. I have tried a bunch of other things but to no avail. Can someone help me with this?
CODE
*{
padding: 0px;
margin: 0px;
box-sizing: border-box;
font-family: Poppins, sans-serif;
color: #00255A;
}
.card-container{
display: flex;
height: 80%;
justify-content: space-evenly;
align-items: center;
flex-wrap: wrap;
}
.card{
background-color: white;
width:25%;
height: 70%;
border-radius: 5%;
transition: .5s ease;
border: 3px solid #00255A;
overflow: hidden;
}
.card-heading{
text-align: center;
padding: 15px;
text-transform: uppercase;
border-bottom: 3px dotted #00255A;
margin: 10px;
}
.card-body{
margin-top: 15px;
margin: 2%;
}
.card-price{
width: 60%;
margin: auto;
text-align: center;
margin-top: 10%;
font-size: larger;
}
.card-features{
margin-top: 4%;
}
ul{
text-align: center;
list-style: none;
}
ul li{
padding: 5px;
font-size: small;
font-weight: light;
}
.btn-container{
text-align: center;
margin-top: 10px;
}
.btn-container button{
width:150px;
height: 40px;
background-color: white;
font-weight: bold;
border: 3px solid #00255A ;
transition: .5s ease-out;
}
.recommended{
position: absolute;
background-color: red;
width:150px;
top: 5px;
left:-18px;
transform: rotate(-30deg);
padding-left: 15px;
}
.recommended h4{
font-weight: lighter;
text-transform: uppercase;
color: white;
}
/* Hover Effects */
.btn-container button:hover{
background-color: #00255A;
color: white;
box-shadow: 4px 4px 5px lightgray;
}
.card:hover{
box-shadow: 2px 2px 3px lightgray;
transform: translateY(-5px);
}
<div class="card-container">
<!-- Student Plan Card -->
<div class="card">
<div class="card-heading">
<h3>Student</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>19.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>15GB Cloud Storage</li>
<li>Upto 5 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Team Plan Card -->
<div class="card" style="height: 80%; position: relative;">
<div class="recommended">
<h4>Popular</h4>
</div>
<div class="card-heading">
<h3>Team</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>24.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>40GB Cloud Storage</li>
<li>Upto 10 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Business Plan Card -->
<div class="card" >
<div class="card-heading">
<h3>Business </h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>39.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>100GB Cloud Storage</li>
<li>Unlimited Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
</div>
You have to strictly define the width of the cards. 25% is a relative value, meaning it will shrink to the proper size to fit the container. I added some margins for aesthetic reasons, and added a flex: 1 0 0 - it grows if necessary, doesn't shink (if it does it won't wrap), and each card grows from the basis width defined in width. If you don't want it to grow, just define flex:0 0 auto, or just remove the flex line entirely, and define justify-content: space-evenly.
Note that you can hardcode it using media queries as well. In fact, I would recommend that as having different widths for your cards might be troublesome, and creating a pallette of cards of fixed widths would probably be easier.
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
font-family: Poppins, sans-serif;
color: #00255A;
}
.card-container {
margin-top: 20px;
display: flex;
height: 80%;
justify-content: stretch;
align-items: center;
flex-wrap: wrap;
}
.card {
background-color: white;
width: 250px;
flex: 1 0 auto;
margin: 0 50px 20px 50px;
padding-bottom: 20px;
height: 70%;
border-radius: 5%;
transition: .5s ease;
border: 3px solid #00255A;
overflow: hidden;
}
.card-heading {
text-align: center;
padding: 15px;
text-transform: uppercase;
border-bottom: 3px dotted #00255A;
margin: 10px;
}
.card-body {
margin-top: 15px;
margin: 2%;
}
.card-price {
width: 60%;
margin: auto;
text-align: center;
margin-top: 10%;
font-size: larger;
}
.card-features {
margin-top: 4%;
}
ul {
text-align: center;
list-style: none;
}
ul li {
padding: 5px;
font-size: small;
font-weight: light;
}
.btn-container {
text-align: center;
margin-top: 10px;
}
.btn-container button {
width: 150px;
height: 40px;
background-color: white;
font-weight: bold;
border: 3px solid #00255A;
transition: .5s ease-out;
}
.recommended {
position: absolute;
background-color: red;
width: 150px;
top: 5px;
left: -18px;
transform: rotate(-30deg);
padding-left: 15px;
}
.recommended h4 {
font-weight: lighter;
text-transform: uppercase;
color: white;
}
/* Hover Effects */
.btn-container button:hover {
background-color: #00255A;
color: white;
box-shadow: 4px 4px 5px lightgray;
}
.card:hover {
box-shadow: 2px 2px 3px lightgray;
transform: translateY(-5px);
}
<div class="card-container">
<!-- Student Plan Card -->
<div class="card">
<div class="card-heading">
<h3>Student</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>19.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>15GB Cloud Storage</li>
<li>Upto 5 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Team Plan Card -->
<div class="card" style="height: 80%; position: relative;">
<div class="recommended">
<h4>Popular</h4>
</div>
<div class="card-heading">
<h3>Team</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>24.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>40GB Cloud Storage</li>
<li>Upto 10 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Business Plan Card -->
<div class="card">
<div class="card-heading">
<h3>Business </h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>39.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>100GB Cloud Storage</li>
<li>Unlimited Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
</div>
You can view it in full screen and resize the browser to see how the wrapping works.
You have set the with of the card to 25%. You'll need to add a media query (https://wiki.selfhtml.org/wiki/CSS/Media_Queries) so you can set another with when the screen is too small.
.card{
width: 50%;
}
#media (min-width: 1200px){
.card{
width: 30%
}
}
Use hard code for width to wrap else you can use #media for different screen sizes if you want to use soft code .
Add margin and padding according to need
#media like this :
#media (max-width: 776px){
.card {
width: 48%;
margin: 2% 1%;
}
}
#media (max-width: 500px){
.card {
width: 90%;
margin: 2% auto;
}
}
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
font-family: Poppins, sans-serif;
color: #00255A;
}
.card-container {
display: flex;
height: 80%;
justify-content: space-evenly;
align-items: center;
flex-wrap: wrap;
}
.card {
background-color: white;
width: 300px;
height: 70%;
margin: 5px; /*Add according to need*/
border-radius: 5%;
transition: .5s ease;
border: 3px solid #00255A;
overflow: hidden;
}
.card-heading {
text-align: center;
padding: 15px;
text-transform: uppercase;
border-bottom: 3px dotted #00255A;
margin: 10px;
}
.card-body {
margin-top: 15px;
margin: 2%;
}
.card-price {
width: 60%;
margin: auto;
text-align: center;
margin-top: 10%;
font-size: larger;
}
.card-features {
margin-top: 4%;
}
ul {
text-align: center;
list-style: none;
}
ul li {
padding: 5px;
font-size: small;
font-weight: light;
}
.btn-container {
text-align: center;
margin-top: 10px;
}
.btn-container button {
width: 150px;
height: 40px;
background-color: white;
font-weight: bold;
border: 3px solid #00255A;
transition: .5s ease-out;
}
.recommended {
position: absolute;
background-color: red;
width: 150px;
top: 5px;
left: -18px;
transform: rotate(-30deg);
padding-left: 15px;
}
.recommended h4 {
font-weight: lighter;
text-transform: uppercase;
color: white;
}
/* Hover Effects */
.btn-container button:hover {
background-color: #00255A;
color: white;
box-shadow: 4px 4px 5px lightgray;
}
.card:hover {
box-shadow: 2px 2px 3px lightgray;
transform: translateY(-5px);
}
<div class="card-container">
<!-- Student Plan Card -->
<div class="card">
<div class="card-heading">
<h3>Student</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>19.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>15GB Cloud Storage</li>
<li>Upto 5 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Team Plan Card -->
<div class="card" style="height: 80%; position: relative;">
<div class="recommended">
<h4>Popular</h4>
</div>
<div class="card-heading">
<h3>Team</h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>24.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>40GB Cloud Storage</li>
<li>Upto 10 Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
<!-- Business Plan Card -->
<div class="card">
<div class="card-heading">
<h3>Business </h3>
</div>
<div class="card-body">
<div class="card-price">
<h1>39.99/mo</h1>
</div>
<div class="card-features">
<ul>
<li>24/7 Live Support</li>
<li>100GB Cloud Storage</li>
<li>Unlimited Users</li>
</ul>
</div>
</div>
<div class="btn-container">
<button>Buy Now!</button>
</div>
</div>
</div>
How do I size a vertical line using css?
I need my vertical line to match the size of the frame. The vertical line must be in the center and must divide the frame into two equal sizes. Or is there any other way to output a vertical line?
Below is my html and css code:
body {
background-color: rgb(40, 40, 40);
}
.card {
text-align: center;
padding-left: 20%;
padding-right: 20%;
background-color: rgb(40, 40, 40);
}
#myPug {
width: 300px;
height: 300px;
border-radius: 50%;
margin-top: 20px;
}
.fact {
font-size: 30px;
}
.factList {
font-family: cursive;
font-size: 25px;
}
ul {
list-style-type: none;
}
.listContent {
text-align: left;
}
.info {
font-family: inherit;
font-size: 30px;
color: rgb(0, 0, 0);
}
.infoBox {
border-style: solid;
border-color: rgb(55, 150, 210);
border-radius: 10%;
margin-left: 30%;
margin-right: 30%;
margin-top: 30px;
padding-top: 20px;
}
.topic {
text-align: left;
}
.topicDescription {
text-align: right;
}
.prop {
margin-left: 20px;
}
.vl {
align-self: center;
border-left: solid;
padding-top: 0;
padding-bottom: 0;
color: black;
height: 200px;
}
.length {
width: 1;
size: 500;
}
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="card">
<img id="myPug" src="images/burfi.jpg" alt="A cute pug's pic">
<div class="infoBox">
<div class="row">
<div class="col-md-5">
<p class="info prop">Name:</p>
<p class="info prop">Age: </p>
<p class="info prop">Breed: </p>
</div>
<div class="col-md-2">
<div class="vl"> </div>
</div>
<div class="col-md-5">
<p class="info def"><em> BURFI</em></p>
<p class="info def"><em> 2 Yrs</em></p>
<p class="info def"><em> Pug</em></p>
</div>
</div>
</div>
</div>
Below is a snapshot of my webpage:
The .infoBox has a padding-top: 20px that is causing the space. If you want some padding, do it with the inner columns.
A flexbox solution without Bootstrap
.box {
display: inline-block;
border: 1px solid;
padding: 0 50px;
}
.box img {
display: block;
max-width: 100%;
height: auto;
}
.box ul {
list-style: none;
padding: 0;
}
.box .vl {
width: 3px;
height: 100%;
background: black;
}
.box .info {
display: flex;
justify-content: center;
border: 3px solid;
border-radius: 10px;
margin-top: 30px;
}
.box .info>div:nth-child(1),
.box .info>div:nth-child(3) {
padding: 0 30px;
}
<div class="box">
<img src="http://placehold.it/300x300" alt="">
<div class="info">
<div>
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul>
</div>
<div>
<div class="vl"></div>
</div>
<div>
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul>
</div>
</div>
</div>
I cannot get my .container{} to encompass all the content on my web page. My lower navigation buttons are sitting outside the container (marked by a 1px black border) and I can't figure out why. I'm not sure where I've went wrong in my CSS or HTML code! Thanks in advance for your help. Here is a link to my CodePen: https://codepen.io/IDCoder/pen/rGWeEE?editors=0100
Here are my code snippets:
<html>
<head>
<title>Ms.Jane Equities Management Corp</title>
</head>
<body>
<div class="container-fluid">
<!-- Top Box -->
<div class="wrap">
<div class="Logos">
<img src="https://s26.postimg.org/iqkxecqnd/Coldwell_Banker-_Logo_RS1.jpg" width="150" height="82"/>
<img src="https://s26.postimg.org/iqkxecqnd/Coldwell_Banker-_Logo_RS1.jpg" width="150" height="82"/> </div>
<div class ="nav wrap">
<!--navigation buttons-->
<ul class="navigation">
<li id="NAV-ONE">LOG IN</li>
<li id="NAV-TWO">BUY A HOME</li>
<li id="NAV-THREE">SELL A HOME</li>
<li id="NAV-FOUR">CONTACT US</li>
</ul>
</div>
</div>
<!-- Middle Box -->
<div class="row two">
<div>
<div class="floater box">
<!--<div class="search box wrap">
<div class="search">
<input type="text" class="searchTerm" placeholder="What are you looking for?">
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
</div>-->
</div>
</div>
</div>
<!-- Bottom Box -->
<div class="row three">
<div class ="nav wrap 2">
<!--navigation buttons-->
<ul class="navigation">
<li id="NAV-A">MY LISTINGS</li>
<li id="NAV-B">COMMUNITIES SERVED</li>
<li id="NAV-C">PROPERTIES</li>
</ul>
</div>
</div>
</div>
</body>
<html>
CSS:
.container-fluid{
border: 1px solid #000000;
max-width: 1600px;
/*overflow: hidden;*/
}
.wrap{
background-color: yellow;
display: inline: flex;
/*overflow: hidden;*/
}
.Logos{
width: 55%;
display: inline-block;
background-color: blue;
}
.nav.wrap{
display: inline-block;
background-color: green;
float: right;
margin-top: 25px;
}
ul.navigation{
font: bold 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
/*text-align center;*/
/*border: 1px solid green;*/
/*overflow: hidden;*/
}
.navigation li {
display: inline-block;
}
.navigation a {
background: #395870;
background: linear-gradient(#49708f, #293f50);
border-right: 1px solid rgba(0, 0, 0, .3);
color: #fff;
padding: 12px 20px;
text-decoration: none;
}
.navigation a:hover {
background: #314b0;
box-shadow: inset 0 0 10px 1px rgba(0, 0, 0, .3);
}
.navigation li:first-child a {
border-radius: 4px 0 0 4px;
}
.navigation li:last-child a {
border-right: 0;
border-radius: 0 4px 4px 0;
}
.row.two{
background-image: url(https://s1.postimg.org/5gvbly4hin/East_Hyde_Park_Chicago_aerial_0470.jpg);
background-position: absolute;
background-size:cover;
background-repeat: no-repeat;
max-width: 1600px;
height: 550px;
margin: auto;
}
.floater.box{
background-color: white;
border-radius: 10px;
opacity: .45;
max-width: 75%;
height: 200px;
position: absolute;
top:50%;
left: 0;
right: 0;
margin: auto;
}
/*.search {
width: 50%;
position: relative
}
.searchTerm {
float: left;
width: 100%;
border: 3px solid #00B4CC;
padding: 5px;
height: 20px;
border-radius: 5px;
outline: none;
color: #9DBFAF;
}
.searchTerm:focus{
color: #00B4CC;
}
.searchButton {
position: absolute;
right: -50px;
width: 40px;
height: 36px;
border: 1px solid #00B4CC;
background: #00B4CC;
text-align: center;
color: #fff;
border-radius: 5px;
cursor: pointer;
font-size: 20px;
}
.search.box.wrap{
width: 30%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
*/
I think your div.nav.wrap is getting pushed down because it's floated and there's no room for it in the container and because it's floated the container doesn't adjust for it. If you remove the float, you'll see the container start to contain it. That's normal float behaviour - elements with float are out of the 'flow' of the document so other elements aren't affected by them.
I'd just add a negative top margin to push it back up. I'd usually do this in rem or depending on how you size the nav height. So your existing .nav.wrap rule would become:
.nav.wrap{
display: inline-block;
background-color: green;
float: right;
margin-top: -35px;
}