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.
Related
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;
}
}
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>
I want to build the following simple UI, but I am having a rough time coding it in the right way to achieve those multiples rectangles as table layout. I could code a really bad matrix, but how can I achieve the following design using HTML, and CSS , I know it;s really simple , but I am not sure how to correctly
.flex-container {
padding: 0;
margin: 0;
list-style: none;
max-height: 600px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column wrap;
justify-content: space-around;
flex-direction: column;
}
.flex-item {
display: flex;
}
.ex-col {
width: 100%;
max-width: 420px;
background: white;
padding: 20px;
color: #555;
}
.ex-col h2 {
font-size: 1.1em;
line-height: 1.3em;
text-align: center;
font-weight: bold;
margin: 0 0 10px;
padding: 0 0 10px;
border-bottom: 1px solid slategray;
width: 100%;
font-weight: bold;
}
.ex-col h2>small {
display: block;
font-size: .9rem;
line-height: 1.3rem;
font-weight: normal;
}
.ex-list {
list-style: none;
padding: 0;
margin: 0;
display: grid;
grid-gap: 10px;
}
/* The list item element. Must be FLEX */
.ex-list>li {
display: flex;
align-items: center;
min-height: 70px;
}
/* The list heading element */
.ex-list h3 {
font-size: 1em;
line-height: 1.4em;
padding: 6px 8px;
border: 1px solid slategray;
display: flex;
align-items: center;
/* Set flex size to 50% of the parent element width.
This is a good way to make sure it is always 50% */
flex-basis: 100%;
max-width: 50%;
cursor: pointer;
margin: 0;
}
.ex-list h3>small {
font-size: .6em;
line-height: 1em;
color: lightgray;
margin: 0 0 0 .5em;
}
/* The sub-menu element. Initial state is display:none */
.ex-list-sub {
display: none;
list-style: none;
padding: 0 0 0 20px;
margin: 0;
position: relative;
flex-basis: 100%;
max-width: 50%;
transition: opacity .4s ease-out;
border: 1px solid gray;
border-left: none;
}
.ex-list-sub:before {
content: "";
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 20px;
background: gray;
}
.ex-list-sub>li:not(:first-child) {
border-top: 1px solid gray;
}
.ex-list-sub>li>a {
display: block;
padding: 6px 8px;
color: inherit;
text-decoration: none;
transition: background .2s;
}
.ex-list-sub>li>a:hover {
background: #efefef;
}
/* THE HOVER ACTION */
/* Set the hover on the parent element.
Has to be the parent because otherwise the pop-up would disappear when you hover over it */
.ex-list>li:hover .ex-list-sub {
display: block;
}
<div class="flex-container">
<div class="flex-item">
<div class="ex-col">
<h2>
Reconnaissance
<small>10 Techniques</small>
</h2>
<ul class="ex-list">
<li>
<h3>
Active Scanning
<small>(0/2)</small>
</h3>
<ul class="ex-list-sub">
<li>
<a href="#">
Scanning IP Blocks
</a>
</li>
<li>
<a href="#">
Vulnerability Scanning
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="ex-col">
<h2>
Reconnaissance
<small>10 Techniques</small>
</h2>
<ul class="ex-list">
<li>
<h3>
Active Scanning
<small>(0/2)</small>
</h3>
<ul class="ex-list-sub">
<li>
<a href="#">
Scanning IP Blocks
</a>
</li>
<li>
<a href="#">
Vulnerability Scanning
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
Something like this maybe? I replicated it from your screenshot, is it missing anything?
.column{
float:left;
margin:0 10px 0 0;
width:120px;
}
.column .option{
margin:10px 0 0 0;
padding:10px;
background:grey;
}
.column .option:first-child{
background:tomato;
}
<div class="column">
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
</div>
<div class="column">
<div class="option">Some text here</div>
<div class="option">Some text here</div>
</div>
<div class="column">
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</div>
<div class="option">Some text here</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;
}