Add empty space between div's content and bottom border - html

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>

Related

How come one of my images aren't displaying next to each other?

I'm trying to line up 3 images and some text on one 'line', the first 2 images are lined up fine, same with the text but the 3rd image refuses to and i'm not sure why.
here is my code so far:
* {
box-sizing: border-box;
}
body {
display: inline-block;
width: 800px;
height: 1000px;
}
.logo {
padding: 5px;
display: inline;
}
.pfp {
display: inline;
}
.msg {
display: inline;
}
.userid {
text-decoration-color: white;
background-color: rgb(250, 250, 250);
text-align: left;
width: 50px;
border-radius: 20%;
display: block;
font-size: 10px;
margin-left: 160px;
margin-top: -18px;
}
<div class='logo'>
<img src='logo.jpg' , width=1 00px>
</div>
<div class="pfp">
<a href="Profile Page.html">
<img src='pfp.jpg' , width=5 0px>
</a>
</div>
<div class='userid'>
<span>[user_id]</span>
</div>
<div class='msg'>
<a href='messages.html'>
<img src='messages.jpg' , width=5 0px>
</a>
</div>
Your .userid also needs to be displayed inline or inline-block so the next item can be inline with it. Right now it's displayed as block so it's shoving anything after it to the next line.
* {
box-sizing: border-box;
}
body {
display: inline-block;
width: 800px;
height: 1000px;
}
.logo {
padding: 5px;
display: inline;
}
.pfp {
display: inline;
}
.msg {
display: inline;
}
.userid {
text-decoration-color: white;
background-color: rgb(250, 250, 250);
text-align: left;
width: 50px;
border-radius: 20%;
//display: block;
display: inline;
font-size: 10px;
margin-left: 160px;
margin-top: -18px;
}
<div class='logo'>
<img src='logo.jpg' , width=1 00px>
</div>
<div class="pfp">
<a href="Profile Page.html">
<img src='pfp.jpg' , width=5 0px>
</a>
</div>
<div class='userid'>
<span>[user_id]</span>
</div>
<div class='msg'>
<a href='messages.html'>
<img src='messages.jpg' , width=5 0px>
</a>
</div>

CSS Menu underlaping on hover

I have a mega menu which is vertically above a div that contains image banners. When hovering over this mega menu it expands displaying content. When expanding the content goes under the images in the image banner div making them not visible. I want it to be on top of the image banner div when I hover over mega menu links.
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0; margin: 0;
}
body {
}
.wrapperss {
font-size: 1.6em;
padding: 2em;
margin: 0 auto;
width: 95%;
background-color: white;
z-index: 999;
}
/* Navigation Bar Styling */
.navSuper {
background: white;
width: 100%;
height: 43px;
position: relative;
border: 1px solid #B2BEB5;
}
.navSuper li {
list-style: none;
float: left;
text-align: center;
width: 33%;
width: calc(100% / 3);
}
.navSuper > li > a {
color: #536267;
font-weight: bold;
font-size: .7em;
text-decoration: none;
line-height: 43px;
padding: 0 20px;
height: 43px;
text-transform: uppercase;
}
.navSuper > li:hover {
border-right: 1px solid #b2beb5;
border-left: 1px solid #b2beb5;
}
.navSuper > li:hover > div {
display: block;
}
.navSuper > li > div {
position: absolute;
left: 0;
top: 41px;
display: none;
background-color: white;
padding: 10px 10px;
box-shadow: 2px 4px 4px rgba(0,0,0,0.4);
overflow: hidden;
}
.nav-mainCustom{
width: 100%;
border: 1px solid #b2beb5;
}
.nav-dividerCustom {
display: inline-block;
width: 1.8%;
}
.nav-focus-artCustom {
display: inline-block;
width: 11.5%;
vertical-align: top;
text-align: center;
}
.nav-art-authorCustom, .nav-art-titleCustom{
display: inline-block;
padding: 10px 0px;
}
.nav-art-authorCustom {
font-size: .9em;
color: red;
}
.nav-art-titleCustom {
font-size: 1.4em;
}
.nav-art-imageCustom {
display: inline-block;
}
.nav-divider-2Custom {
display:inline-block;
width: 3.8%;
}
.nav-headlinesCustom {
display:inline-block;
width: 34.5%;
font-size: 1.2em;
font-weight: bold;
text-align: left;
padding-right: 3px;
}
.nav-headline-linkCustom {
border-bottom: 1px solid #b2beb5;
padding: 10px 0px;
}
.nav-headline-linkCustom:last-child {
border-width: 0px;
}
.nav-linksCustom{
display: inline-block;
width: 11.95%;
vertical-align: top;
text-align: left;
}
.nav-linkCustom{
/*padding-bottom: 20px; */
}
.nav-empty-cellCustom{
}
.nav-headline-linkCustom:first-child{
color: red;
}
.nav-linkCustom:first-child{
color: red;
}
<div class="wrapperss">
<ul class="navSuper">
<li>Title 1
<div class="nav-mainCustom">
<div class="nav-divider"></div>
<div class="nav-focus-artCustom">
<img class="nav-art-imageCustom" src="http://example image" alt="article image"/>
<span class="nav-art-authorCustom">Title 2</span> <br>
<span class="nav-art-titleCustom">Product 1</span>
</div>
<div class="nav-divider-2Custom"></div>
<div class="nav-focus-artCustom">
<img class="nav-art-imageCustom" src="http://exampleimage" alt="article image"/>
<span class="nav-art-authorCustom">Title 3</span><br>
<span class="nav-art-titleCustom">Product 2</span>
</div>
<div class="nav-divider-2Custom"></div>
<div class="nav-headlinesCustom">
<div class="nav-headline-linkCustom">New Products</div>
<div class="nav-headline-linkCustom">Product 1 Desctiption</div>
<div class="nav-headline-linkCustom">Product 2 Desctiption</div>
<div class="nav-headline-linkCustom">Product 3 Desctiption</div>
<div class="nav-headline-linkCustom">Product 4 Desctiption</div>
<div class="nav-headline-linkCustom">Product 5 Desctiption</div>
</div>
<div class="nav-divider-2Custom"></div>
<div class="nav-linksCustom">
<div class="nav-linkCustom">Categories</div>
<div class="nav-linkCustom">CAt 1</div>
<div class="nav-linkCustom">Cat 2</div>
<div class="nav-linkCustom">Cat 3</div>
<div class="nav-linkCustom">Cat 4</div>
</div>
<div class="nav-linksCustom">
<div class="nav-empty-cellCustom"></div>
<div class="nav-linkCustom">Test 1</div>
<div class="nav-linkCustom">Cat 5</div>
<div class="nav-linkCustom">Cat 6</div>
<div class="nav-linkCustom">Cat 7</div>
<div class="nav-linkCustom">Cat 8</div>
</div>
In .navSuper class use
z-index: 99;

Push content to the left to reveal delete button

How would I go about doing that;
this is my current wip:
https://jsfiddle.net/Lg0wyt9u/967/
<li>
<div class='type'><i class='fa fa-arrow-circle-right'>I</i></div>
<div class='details'>
<div class='date'>date</div>
<div class='address'>1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
</div>
<div class='value'>1.2</div>
<div class='slide-in'>
DELETE
</div>
</li>
The delete button is hidden for the moment.
What should happen is, it gets revealed, and the other content is pushed "off-canvas" to the same width as this element. However, I'm unsure of how to proceed. I use display:flex and tried some positioning but it didn't work.
Here you go:-
$(document).ready(function(){
$('.list ul li .rw').click(function(){
console.log(this);
$(this).css("right","65px");
$('.slide-in').css("display","block");
})
})
ul {
list-style-type: none;
margin: 0;
padding: 0;
border: 1px solid black;
}
.rw{
padding-top: 20px;
width:100%;
cursor:pointer;
position:absolute;
padding-bottom: 20px;
border-bottom: 1px solid #a1d1b8;
display: flex;
justify-content: space-between;
align-items: center;
}
.type {
padding-right: 15px;
flex: 0 0 50px;
background: green;
}
.type i {
font-size: 40px;
}
.details {
flex: 1;
overflow: hidden;
font-family: "Courier New";
}
.address {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.value {
padding-left: 15px;
font-size: 55px;
}
.date {
font-weight: bold;
margin-bottom: 5px;
}
.slide-in {
width:65px;
background: red;
color: #fff;
display:none;
}
<div id="container">
<div class="list">
<ul>
<li>
<div class="rw">
<div class='type'><i class='fa fa-arrow-circle-right'>I</i></div>
<div class='details'>
<div class='date'>date</div>
<div class='address'>1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
</div>
<div class='value'>1.2</div>
<div class='slide-in'>
DELETE
</div>
</div>
</li>
</ul>
</div>
</div>
You have include jQuery for this solution...

How to place p tag under image?

So i'm trying to place some text under an image but for some reason it stays on the right till the container ends and then goes under the image.
I want it to be fully under the image.
And here is the code:
.post {
margin-top: 3px;
width: 80%;
font-size: 20px;
border-bottom: 1px solid #ddd;
}
.post h2 {
font-size: 20px;
cursor: pointer;
}
.post h2:hover {
color: #0099FF;
}
.post img {
display: block;
width: 95%;
height: auto;
float: left;
position: relative;
}
.post p {
display: block;
top: 7px;
font-size: 13px;
color: #999;
}
.rating {
display: inline-block;
}
.rate {
display: inline-block;
height: 34px;
width: 44px;
border: 1px solid #ddd;
border-radius: 3px;
text-align: center;
cursor: pointer;
line-height: 30px;
margin-bottom: 25px;
margin-left: 5px;
}
.rate:first-child {
margin-left: 0;
}
.rate:hover {
border: 1px solid #999;
}
.rate img {
position: relative;
top: 7px;
left: 12px;
width: 20px;
height: 20px;
}
.social {
display: inline-block;
height: 34px;
float: right;
}
.social a img {
display: inline-block;
height: 34px;
width: auto;
margin-right: 10px;
}
<div class="post">
<h2>I know I'm a douche for wearing sunglasses at night but...</h2>
<img src="http://img-9gag-fun.9cache.com/photo/a77Pzr2_700b.jpg" />
<div class="postfooter">
<p>Over 9000 points ยท 56 comments</p>
<div class="rating">
<div class="rate">
<img src="up.png">
</div>
<div class="rate">
<img src="down.png">
</div>
<div class="rate">
<img src="comment.png">
</div>
</div>
<div class="social">
<a href="#">
<img src="facebook.png">
</a>
<a href="#">
<img src="twitter.png">
</a>
<a href="#">
<img src="googleplus.png">
</a>
</div>
</div>
Also it looks alright in chrome for some reason and not alright in FF.
Add css for .postfooter
.postfooter {
clear: both;
}
This will ensure it's on its own line.

How to stop div from pushing other divs down?

I have some divs.
I am using a Grid system and I cannot for the life of me figure out how to stop divs from pushing others down.
When I try to set the margin top to say 50px for the border div it pushes everything else down.
I do not want to use position absolute due to being responsive grid system.
body {
font-size: 100%;
font-family: Lato;
}
img {
width: 100%;
height: auto;
max-height: 640px;
}
h2 {
font-size: 3.2em;
font-weight: 300;
text-align: center;
margin-top: 160px;
}
ul {
text-align: center;
margin-top: 100px;
overflow: hidden;
margin-right: 25px;
}
ul > li {
display: inline-block;
padding: 0 25px;
font-size: 1.1rem;
}
#circle {
font-size: 1.2rem;
border: 1px solid black;
border-radius: 5px 20px 5px;
padding: 0 20px;
}
.border {
overflow: hidden;
border: 2px solid black;
margin-top:;
}
<div class="cover">
<div class="grid">
</div>
<div class="row">
<div class="c12">
<div class="border"></div>
<div class="clear"></div>
<ul>
<li id="circle">H</li>
<li>Home</li>
<li id="circle">A</li>
<li>About</li>
<li id="circle">W</li>
<li>Work</li>
<li id="circle">C</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="row">
<div class="c12">
<h2>Exquisite Web Development</h2>
</div>
</div>
</div>
</div>
On the border div, you can remove the margin and add:
position: relative;
top: 50px;
Seems to me that the problematic margin is here:
ul {
margin-top: 100px;
}
Remove or shrink that and add your margin to .border as intended.
body {
font-size: 100%;
font-family: Lato;
}
img {
width: 100%;
height: auto;
max-height: 640px;
}
h2 {
font-size: 3.2em;
font-weight: 300;
text-align: center;
margin-top: 160px;
}
ul {
text-align: center;
overflow: hidden;
margin-right: 25px;
}
ul > li {
display: inline-block;
padding: 0 25px;
font-size: 1.1rem;
}
#circle {
font-size: 1.2rem;
border: 1px solid black;
border-radius: 5px 20px 5px;
padding: 0 20px;
}
.border {
overflow: hidden;
border: 2px solid black;
margin-top: 50px;
;
}
<div class="cover">
<div class="grid"></div>
<div class="row">
<div class="c12">
<div class="border"></div>
<div class="clear"></div>
<ul>
<li id="circle">H</li>
<li>Home</li>
<li id="circle">A</li>
<li>About</li>
<li id="circle">W</li>
<li>Work</li>
<li id="circle">C</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="row">
<div class="c12">
<h2>Exquisite Web Development</h2>
</div>
</div>
</div>
Try using:
position: relative;
top: 50px;
Here is a pen: http://codepen.io/anon/pen/GpyMKp
For your border div. This is a way to move an element from it's usual position without affecting the other divs.
Although I feel like you would be better off just reducing the margin-top on your ul element, and you could achieve the same layout without it being a sort of "hacky" solution.