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>
Related
I'm trying everything, I'm new at this and just cannot get it to work.
I just wanted my logo ("animated") to always align left, and the links to align right. Just like any normal nav bar.
The animated logo works just fine. I just can't separate the logo from the links and align them?
I've tried float: right and margin-right: auto under the animated logo.
.container {
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</nav>
Add width: 100vw; to the .container.
You only set max-width, which is not enough because the width will be "auto" if there's not enough content, but never more than 1280px.
You want the width to be 100vw if there's not enough content, but never more than 1280px.
See the snippet below.
.container {
width: 100vw; /* Added */
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
.menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
<body>
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</div>
</nav>
</body>
EDIT 1
.container {
width: 100vw; /* Added */
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
.menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
/* Added */
nav {
display: flex;
justify-content: space-around;
}
<body>
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</div>
</nav>
</body>
EDIT 2
Github 1440px:
Github 2560px:
What I usually use for navbars is a display: flex;
If I understood correctly what you want to do is organise the elements horizontally in the bar, to do that you can give the container class the following properties:
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: space-around;
}
If that doesn't suit your needs or if you want more informations about flex boxes I'd recommend this website: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
It explains all you need to know about flex boxes and could help you find a solution to your problem.
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 simply have 1 smaller div (navigation menu) in a bigger div (header).
And i need the border-bottom of the smaller div to be on the same height as the border-bottom of the bigger div.
I've attached to pictures:
have
want
.main-navigation-link .main-navigation-link-text {
border-bottom: 6px solid #F18000;
color: #F18000;
padding-bottom: 7px;
}
.nav {
display: flex;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.nav-main {
border-bottom: 7px solid red;
}
<div class="nav-main fixed-header">
<div class="main-navigation" id="mainNavigation" data-flyout-menu="true">
<div class="container">
<nav class="nav main-navigation-menu">
<a class="nav-link main-navigation-link">
<div class="main-navigation-link-text">
<span itemprop="name">Dönermesser</span>
</div>
</a>
</nav>
</div>
</div>
</div>
JSFiddle
Try to set margin on smaller div margin-bottom: -5px; (or value of border thickness of bigger div)
.main-navigation-link .main-navigation-link-text {
border-bottom: 6px solid #F18000;
color: #F18000;
padding-bottom: 6px;
margin-bottom: -6px;
}
.nav {
display: flex;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.nav-main {
border-bottom: 6px solid red;
}
<div class="nav-main fixed-header">
<div class="main-navigation" id="mainNavigation" data-flyout-menu="true">
<div class="container">
<nav class="nav main-navigation-menu">
<a class="nav-link main-navigation-link">
<div class="main-navigation-link-text">
<span itemprop="name">Dönermesser</span>
</div>
</a>
</nav>
</div>
</div>
</div>
You can use :after element on the element with text.
.box {
width: 100px; /* demo only */
padding: 10px;
text-align: center;
border-bottom: 10px solid #ccc;
}
.content {
position: relative;
display: inline-block;
color: orange;
}
.content:after {
content: '';
width: 100%;
height: 3px;
background: orange;
display: block;
position: absolute;
bottom: -13px;
}
<div class="box">
<div class="content">Dönermesser</div>
</div>
I am trying to replicate a full-width rectangle div on a website but I'm having problems with responsiveness and mobility.
Here's an example of what I'm trying to replicate.
And here's what I have so far.
The problem is that the text won't go inside the separate boxes and it breaks in mobile version.
Here's my snippet:
HTML
<div class="row remove-container">
<div class="speech-bubble1 test-text">
<div class="row">
<h3 class="strong-text felinetitle">ADD</h3>
</div>
<div class="row">
<ul id="feline-ul">
<li>
<h6>Heartworm Test</h6>
</li>
<li>
<h6>$25</h6>
</li>
</ul>
</div>
</div>
<div class="speech-bubble speech-bubble-top">
<div class="container" style="padding-top: 35px; padding-bottom: 35px;">
<h3 class="strong-text felinetitle2">
A LA CARTE </h3>
<div class="row">
<div class="col-lg-9">
</div>
<div class="col-lg-4">
<div class="row">
<div class="col-sm-6">
DHPP or DHLPP
</div>
<div class="col-sm-6">
Canine Flu
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.speech-bubble {
position: relative;
background-color: #045faf;
width: 100%;
height: 150px;
color: white;
text-align: center;
font-family: sans-serif;
}
.speech-bubble1 {
position: absolute;
background-color: #045faf;
width: 32%;
height: 150px;
left: 0;
color: white;
text-align: center;
z-index: 1;
font-family: sans-serif;
}
.remove-container {
margin: 0 !important;
padding: 0 !important;
}
.serviceprice {
display: flex;
justify-content: center;
padding-top: 50px;
}
.speech-bubble {
position: relative;
background-color: #045faf;
width: 100%;
height: 150px;
color: white;
text-align: center;
font-family: sans-serif;
}
.speech-bubble1 {
position: absolute;
background-color: #045faf;
width: 32%;
height: 150px;
left: 0;
color: white;
text-align: center;
z-index: 1;
font-family: sans-serif;
}
.remove-container {
margin: 0 !important;
padding: 0 !important;
}
.serviceprice {
display: flex;
justify-content: center;
padding-top: 50px;
}
#feline-ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#feline-ul li{
float: left;
margin-left: 70px;
}
#feline-ul2{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#feline-ul2 li{
float: left;
margin-left: 70px;
}
.test-text{
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-shadow: 18px 0px 35px -23px rgba(0,0,0,0.52);
box-shadow: 18px 0px 35px -23px rgba(0,0,0,0.52);
}
I'm having problems on the second box with my texts not compressing into a square/container. It just goes full width.
I just recreated your structure to show you an minimal example.
tl;dr; Your bootstrap code is not property nested.
What did i do?
I wrapped the row into a container. A container is the element which wraps all rows in it. There is a .container and .container-fluid where the .container-fluid is for full-width layouts. Below a container is a row. A row is always split into 12 parts in bootstrap. You can specify the amount of columns for each display width. Read up on the width breakpoints at the bootstrap grid doc. You will NEVER want to have a .row with a nested .row. A row is always a parent of a column. If you resize my example you will notice that these two columns (.col-md-8 and .col-md-4) are resizing to two 12-width column on small size devices.
And if you have key-value pairs as data i'd recommend to use tables instead of listings. This is just a semantical tip. A list covers just an enumeration like a shopping list. Instead a table is suited for object-like formatting (starting at one attribute): e.g. a dish which has a price.
*{
color: white;
}
footer{
background-color: #045faf;
padding: 20px;
}
#footer--left, #footer--right{
padding: 0 20px;
}
#footer--left{
-webkit-box-shadow: 18px 0px 35px -23px rgba(0,0,0,0.52);
box-shadow: 18px 0px 35px -23px rgba(0,0,0,0.52);
}
table{
width: 100%;
}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
<div class="container">
<div class="row">
<div id="footer--left" class="col-md-4">
<h3>Some Head Text</h3>
<table>
<tr>
<td>Value</td>
<td>25$</td>
</tr>
</table>
</div>
<div id="footer--right" class="col-md-8">
<h3>Some Head Text</h3>
<table>
<tr>
<td>Value</td>
<td>25$</td>
</tr>
</table>
</div>
</div>
</div>
</footer>
Well, your example of code appears to me too overloaded. I would do in this way:
.blocks {
width: 100%;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
.blocks .block {
border: 1px solid #000;
height: 150px;
}
.blocks .block h3 {
text-align: center;
padding: 0;
margin: 0;
}
.blocks .block ul {
list-style-type: none;
padding-left: 0;
}
.blocks .block ul li {
padding: 0 0 0 15px;
margin: 0;
}
.blocks .block ul li:nth-child(1n) {
display: inline;
}
.blocks .block:first-child {
width: 33%;
}
.blocks .block:last-child {
width: 66%;
}
<div class="blocks">
<div class="block">
<h3>Add</h3>
<ul>
<li>Service 1</li>
<li>5$</li>
<br>
<li>Service 2</li>
<li>10$</li>
<br>
<li>Service 3</li>
<li>15$</li>
</ul>
</div>
<div class="block">
<h3>Add</h3>
<ul>
<li>Service 1</li>
<li>5$</li>
<br>
<li>Service 2</li>
<li>10$</li>
<br>
<li>Service 3</li>
<li>15$</li>
</ul>
</div>
</div>
I am attempting to add a bottom border to a div for the purpose of a navigation bar. The effect I am trying to achieve:
Currently, I have the following code:
$("a").click(function() {
$("a").removeClass("current");
$(this).addClass("current");
});
.container {
}
.container .item {
float: left;
list-style-type: none;
margin: 0 1px;
}
.container .item a {
color: black;
text-decoration: none;
background-color: green;
width: 50px;
font-size: 13px;
text-align: center;
font-weight: bold;
display: table-cell;
vertical-align: middle;
height: 40px;
}
.container .item a.current {
border-bottom: 2px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="item">
<a class="current" href="#">Page 1</a>
</div>
<div class="item">
Page 2
</div>
<div class="item">
Page 3
</div>
<div class="item">
Page 4
</div>
<div class="item">
Page 5
</div>
<div class="item">
Page 6
</div>
</div>
I cannot find a way to add the empty space in between the content of the div and the bottom border without it being the same colour as the div background.
As it currently stands you can't do this. You can't add a gap between an element and its own border. You can, however, add the border to its parent element (the div.item element in this case), then add padding-bottom to that same element to separate it from the a element:
$("a").click(function() {
$(".current").removeClass("current");
$(this).parent().addClass("current");
});
.container {
}
.container .item {
float: left;
list-style-type: none;
margin: 0 1px;
}
.container .item a {
color: black;
text-decoration: none;
background-color: green;
width: 50px;
font-size: 13px;
text-align: center;
font-weight: bold;
display: table-cell;
vertical-align: middle;
height: 40px;
}
.container .item.current {
border-bottom: 2px solid red;
padding-bottom: 4px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="item current">
Page 1
</div>
<div class="item">
Page 2
</div>
<div class="item">
Page 3
</div>
<div class="item">
Page 4
</div>
<div class="item">
Page 5
</div>
<div class="item">
Page 6
</div>
</div>
Note that I've also modified your JavaScript to add this .current class to the li element and not the clicked a element.
demo
new css:
.container {
}
.container .item {
float: left;
list-style-type: none;
margin: 0 1px;
border-bottom: 8px solid red;
}
.container .item a {
color: black;
text-decoration: none;
background-color: green;
width: 50px;
font-size: 13px;
text-align: center;
font-weight: bold;
display: table-cell;
vertical-align: middle;
height: 40px;
border-bottom: 4px solid white;
}
.container .item a.current {
}
One more version using :after pseudo element. Unlike other answers this will put white border inside of element, not push the green further outside.
The interesting parts I added/changed:
.container .item a {
...
position: relative;
}
.container .item a.current:after {
content:'';
position: absolute;
left: 0;
bottom: 2px;
height: 2px;
width: 100%;
background-color: #FFF;
}
And here is a demo:
$("a").click(function() {
$("a").removeClass("current");
$(this).addClass("current");
});
.container {
}
.container .item {
float: left;
list-style-type: none;
margin: 0 1px;
}
.container .item a {
color: black;
text-decoration: none;
background-color: green;
width: 50px;
font-size: 13px;
text-align: center;
font-weight: bold;
display: table-cell;
vertical-align: middle;
height: 40px;
position: relative;
}
.container .item a.current {
border-bottom: 2px solid red;
}
.container .item a.current:after {
content:'';
position: absolute;
left: 0;
bottom: 2px;
height: 2px;
width: 100%;
background-color: #FFF;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="item">
<a class="current" href="#">Page 1</a>
</div>
<div class="item">
Page 2
</div>
<div class="item">
Page 3
</div>
</div>
Demo: http://jsfiddle.net/osajfgLc/
Not sure whether this is what you want. Try this. I added a div with class box. This also can be done using css after method.
$("a").click(function() {
$("a").removeClass("current");
$(this).addClass("current");
});
.container {
}
.container .item {
float: left;
list-style-type: none;
margin: 0 1px;
}
.container .item a {
color: black;
text-decoration: none;
background-color: green;
width: 50px;
font-size: 13px;
text-align: center;
font-weight: bold;
display: table-cell;
vertical-align: middle;
height: 40px;
}
.box {
margin-top:2px;
height: 2px;
background-color:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="item">
<a class="current" href="#">Page 1</a>
<div class="box"></div>
</div>
<div class="item">
Page 2
</div>
<div class="item">
Page 3
</div>
<div class="item">
Page 4
</div>
<div class="item">
Page 5
</div>
<div class="item">
Page 6
</div>
</div>