Hello I have three columns that need a right border with a fixed height, not depending on the number of items in the column.
My code
html
<div class="col-sm-2">
<div class="footer-col">
<ul>
<li class="footer-title hidden-xs">Customer Care</li>
<li>Contact us</li>
<li>Help</li>
<li>Shipping</li>
<li>Returns</li>
<li>Size Guide</li>
</ul>
</div>
</div>
<div class="col-sm-2 hidden-xs">
<div class="footer-col">
<ul>
<li class="footer-title">About Us</li>
<li>Our Story</li>
<li>Careers</li>
</ul>
</div>
</div>
<div class="col-sm-2 hidden-xs">
<div class="footer-col">
<ul>
<li class="footer-title">Shortcuts</li>
<li>My Account</li>
<li>Store Locator</li>
<li>Gift Cards</li>
<li>Payment</li>
</ul>
</div>
</div>
.wrapper {
display: inline-block;
background-color: #000000;
width: 100%;
height: 150px;
color: #999999;
}
.col-sm-2 {
float: right;
margin: 0;
width: 32%;
display: inline-block;
height: 90%;
}
.footer-col {
float: right;
margin: 0;
width: 90%;
padding-left: 10px;
display: inline-block;
height: 90%;
}
ul {
display: inline-block;
width: 90%;
height: 100%;
border-right: 1px solid #999999;
list-style: none;
}
li a {
color: #FFFFFF;
}
https://jsfiddle.net/michaelyuen/72dc7xrd/
There are two things:
1) Set ul height to 100%
2) Set height to parent or parent's parent. In this case, it's the wrapper.
OR use table, then you have to fix width instead of height.
https://jsfiddle.net/michaelyuen/72dc7xrd/1/
.wrapper {
display: table-row;
background-color: #000000;
color: #999999;
}
.col-sm-2 {
margin: 0;
padding-left: 10px;
width: 150px;
display: table-cell;
height: 90%;
border-right: 1px solid #999999;
vertical-align: top;
}
.footer-col {
margin: 0;
width: 90%;
display: inline-block;
height: 90%;
}
ul {
display: block;
margin: 0;
padding: 0;
width: 90%;
height: 100%;
list-style: none;
}
li a {
color: #FFFFFF;
}
Try this:
<style>
.verticalLine {
border-left: thick solid #E2C4C4;
margin-top:6px;
width:5px;
height:50px;
left: 408px;
position: absolute;
}
.pull_left {
float:left;
}
.clear {
clear: both;
}
</style>
<div class="col-sm-2">
<div class="footer-col pull_left">
<ul>
<li class="footer-title hidden-xs">Customer Care</li>
<li>Contact us</li>
<li>Help</li>
<li>Shipping</li>
<li>Returns</li>
<li>Size Guide</li>
</ul>
</div>
<div class="verticalLine pull_left"></div>
</div>
<div class="clear"></div>
<div class="col-sm-2 hidden-xs">
<div class="footer-col pull_left">
<ul>
<li class="footer-title">About Us</li>
<li>Our Story</li>
<li>Careers</li>
</ul>
</div>
<div class="verticalLine pull_left"></div>
</div>
<div class="clear"></div>
<div class="col-sm-2 hidden-xs">
<div class="footer-col pull_left">
<ul>
<li class="footer-title">Shortcuts</li>
<li>My Account</li>
<li>Store Locator</li>
<li>Gift Cards</li>
<li>Payment</li>
</ul>
</div>
<div class="verticalLine"></div>
</div>
Try like this: Demo
.col .well {
margin-bottom: -99999px;
padding-bottom: 99999px;
border-right:1px solid #ddd !important;
}
.col-wrap {
overflow: hidden;
}
.well {
min-height:20px;
padding:19px;
margin-bottom:20px;
background:transparent !important;
border-right:1px solid #e3e3e3 !important;
border:none !important;
box-shadow:none !important;
}
HTML:
<div class="container">
<div class="row col-wrap">
<div class="col-sm-2 col">
<div class="footer-col well">
....
</div>
</div>
<div class="col-sm-2 hidden-xs col">
<div class="footer-col well">
....
</div>
</div>
<div class="col-sm-2 hidden-xs col">
<div class="footer-col well">
....
</div>
</div>
</div>
</div>
Try this Create a outer container and apply overflow: hidden and apply margin and padding to the bottom
http://www.bootply.com/YNUeK8I29h
You can use after/before pseudo selectors.
http://jsfiddle.net/s7w4sqLd/
.footer-col ul:after {
position:absolute;
content:" ";
left:0;
top:0;
width:100%;
height:50px;
border-right: solid 1px #2a343f;
}
.footer-col ul{
position:relative;
float:left;
padding-right:10px;
}
.footer-col ul li {
list-style:none;
}
Related
I need to align logo to left and navigation to right and the text in logo and navigation must be aligned bottom of the logo-nav div.
Note: Without flex box
.logo {
float: left;
}
.navigation {
float: right;
}
.clear {
clear: both;
}
<div class="logo-nav">
<div class="logo">Partners</div>
<div class="navigation">
<ul class="nav-ul">
<li class="nav-li">OUR SPIRIT</li>
<li class="nav-li">OUR OFFER</li>
<li class="nav-li">OUR VISIONARY</li>
<li class="nav-li">CONTACT</li>
</ul>
</div>
<div class="clear"></div>
</div>
You can use Flexbox for this. You just need to set margin-left: auto on navigation and align-items: flex-end for vertical-align.
.logo img {
vertical-align: top;
}
.logo-nav, .nav-ul {
display: flex;
align-items: flex-end;
list-style: none;
margin: 0;
}
.navigation {
margin-left: auto;
}
<div class="logo-nav">
<div class="logo"><img src="http://placehold.it/100x50"></div>
<div class="navigation">
<ul class="nav-ul">
<li class="nav-li">OUR SPIRIT</li>
<li class="nav-li">OUR OFFER</li>
<li class="nav-li">OUR VISIONARY</li>
<li class="nav-li">CONTACT</li>
</ul>
</div>
<div class="clear"></div>
</div>
You can also use CSS tables.
.logo img {
vertical-align: top;
}
.logo-nav {
display: table;
width: 100%;
border-bottom: 1px solid black;
}
ul {
margin: 0;
}
.logo,
.navigation {
display: table-cell;
vertical-align: bottom;
}
.navigation {
text-align: right;
}
li {
display: inline-block;
}
<div class="logo-nav">
<div class="logo">
<img src="http://placehold.it/100x50">
</div>
<div class="navigation">
<ul class="nav-ul">
<li class="nav-li">OUR SPIRIT</li>
<li class="nav-li">OUR OFFER</li>
<li class="nav-li">OUR VISIONARY</li>
<li class="nav-li">CONTACT</li>
</ul>
</div>
<div class="clear"></div>
</div>
.logo-nav{
height:40px;
border-bottom:1px solid black;
width:100%;
margin:0;
padding:0;
}
.navigation{
float:right;
margin:0;
padding:0;
height:100%;
}
.navigation ul{
margin:0;
padding:0;
height:100%;
}
.navigation ul li{
margin:0;
padding:0;
float:left;
margin:0 5px;
list-style-type:none;
display:flex;
align-items:flex-end;
height:100%;
}
.logo{
float:left;
margin:0;
padding:0;
height:100%;
display:flex;
align-items:flex-end;
}
<div class="logo-nav">
<div class="logo">+CoPartners</div>
<div class="navigation">
<ul class="nav-ul">
<li class="nav-li">OUR SPIRIT</li>
<li class="nav-li">OUR OFFER</li>
<li class="nav-li">OUR VISIONARY</li>
<li class="nav-li">CONTACT</li>
</ul>
</div>
<div class="clear"></div>
</div>
Add the following css
.nav-ul li{float:left; list-style:none;padding:0 5px;}
.nav-ul{padding:0;margin:0;}
Since this is not possible with floats, you can use display: inline-block instead. It works like a poor man's flex.
.logo-nav {
text-align: justify;
}
.logo-nav::after {
/* you can omit this by using `text-align-last` */
content: '';
width: 100%;
display: inline-block;
}
.logo {
display: inline-block;
vertical-align: middle;
text-align: left;
width: 50%;
}
.navigation {
display: inline-block;
vertical-align: bottom;
text-align: right;
width: 50%;
}
.clear {
/* this element is obsolete now */
}
Note: there must be no space between .logoand .navigation in your markup.
Are you allowed to use position absolute?
li{
float: left;
padding: 0 5px;
}
ul{
list-style: none;
position: absolute;
right: 0;
margin: 0;
bottom: 0;
}
img{
display: block;
}
.logo{
float: left;
}
.logo-nav{
background: lightblue;
position: relative;
}
.logo-nav:after{
display: block;
clear: both;
content: "";
}
<div class="logo-nav">
<div class="logo"><img src="http://placehold.it/100x50"></div>
<div class="navigation">
<ul class="nav-ul">
<li class="nav-li">OUR SPIRIT</li>
<li class="nav-li">OUR OFFER</li>
<li class="nav-li">OUR VISIONARY</li>
<li class="nav-li">CONTACT</li>
</ul>
</div>
<div class="clear"></div>
</div>
I'm pulling my hair out trying to get two div tags to align. I've read page after page of solutions on here but I've not been able to get any of them to work. I'm not sure if this is related to this being a Visual Studio project using MVC. It seems unlikely but I thought I'd mention it.
So this is for a header bar on a company website. Logo should be on the left and the menu should be on the right. It must be responsive. Here's what I've got so far:
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
logo {
float: none;
width: 215px;
}
nav {
width: 100%;
height: 100%;
float: left;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
And here is the HTML
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</header>
By changing your CSS like this (note the added dot in .logo)
.logo {
float: left;
width: 215px;
}
nav {
margin-left: 215px;
}
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
.logo {
float: left;
width: 215px;
}
nav {
margin-left: 215px;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</header>
You have many problems in your code:
logo in your css should be .logo to refer to the class of the logo.
The property float:none should be set to float:left; so it should be correctly floated.
And for the nav you shouldn't specify a width:100% because it will be forced to take the whole width of the header, you need to set it to auto for example.
This is a working snippet:
header {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
}
.logo {
float: left;
width: 215px;
}
nav {
width: auto;
height: 100%;
float: left;
}
nav ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
nav li {
display: inline;
padding: 20px;
}
nav a {
text-decoration: none;
color: #171581;
padding: 8px 8px 8px 8px;
}
nav a:hover {
color: #D60053;
}
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger"></div>
<nav>
<ul>
<li>About
</li>
<li>Residential & Business
</li>
<li>My Accounts Details
</li>
<li>FAQ
</li>
<li>Contact us
</li>
</ul>
</nav>
</div>
</header>
1.Your code was badly formatted.I have formatted it.
2..logo should be set to "float:left".
3..container should have"overflow:hidden"
I have also made Your li straight.(I have made it in one line )
This contains your html formatted code,Css which You may need to change as well as add
<div style="opacity: 1;" class="wrapper">
<header class="">
<div class="container">
<div class="logo">
<a href="/" class="glyphicon-log-out top-menu">
<img src="~/assets/images/sunwavelogo.png" alt="Sunwave Logo" />
</a>
</div>
<div class="hamburger">
<nav>
<ul>
<li>About</li>
<li>Residential & Business</li>
<li>My Accounts Details</li>
<li>FAQ</li>
<li>Contact us</li>
</ul>
</nav>
</div>
</div>
</header>
</div>
Your css code:
* {
margin: 0px;
padding: 0px;
}
header{
width:700px;
margin:0 auto;
}
.container {
overflow: hidden;
}
.logo {
float: left;
margin-right:100px;
}
.hamburger {
/* float: left; */
overflow: hidden;
}
li {
float: left;
padding: 5px;
list-style-type: none;
}
Hope This Is what You had expected
Fixed div is getting down when I give margin-top to the div below it...why?
* {
margin: 0;
padding: 0;
}
.header_bg {
width: 100%;
height: 100px;
position: fixed;
background: black
}
.container {
width: 960px;
height: auto;
margin: 0 auto
}
ul.menu {
list-style: none;
}
ul.menu li {
display: inline-block
}
ul.menu li a {
text-decoration: none;
color: white
}
.content {
margin-top: 140px
}
<div class="header_bg">
<div class="container">
<ul class="menu">
<li>Home
</li>
<li>About
</li>
<li>Service
</li>
<li>Contact
</li>
</ul>
</div>
</div>
<div class="container">
<div class="content">
/* Content Goes here*/
</div>
</div>
you need to add top:0 to your .header_bg, see more about position
* {
margin: 0;
padding: 0;
}
.header_bg {
width: 100%;
height: 100px;
position: fixed;
background: black;
top:0
}
.container {
width: 960px;
height: auto;
margin: 0 auto
}
ul.menu {
list-style: none;
}
ul.menu li {
display: inline-block
}
ul.menu li a {
text-decoration: none;
color: white
}
.content {
margin-top: 140px
}
<div class="header_bg">
<div class="container">
<ul class="menu">
<li>Home
</li>
<li>About
</li>
<li>Service
</li>
<li>Contact
</li>
</ul>
</div>
</div>
<div class="container">
<div class="content">
/* Content Goes here*/
</div>
</div>
I try to use CSS display:table instead HTML table tags.
My HTML:
<div class="c_result">
<div class="rp-row">
<ul class="rp-first">
<li>London</li>
</ul>
<ul class="rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="rp-result">
<li>result1</li>
<li>result2</li>
<li>result3</li>
</ul>
</div>
<div class="rp-row">
<ul class="rp-first">
<li>Paris</li>
</ul>
<ul class="rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="rp-result">
<li>result4</li>
<li>result5</li>
<li>result6</li>
</ul>
</div>
</div>
My CSS:
.c_result {
border: 1px solid red;
display: table;
width: 100%;
}
.c_result .rp-row {
display: table-row;
border: 1px solid #000;
}
.c_result ul {
display: table-row;
}
.c_result .rp-row li {
display: table-row;
}
The result:
But my desired result is :
The border styles didn't apply too and when I try to use border it doesn't appear in the result , How can I do that ?
Best regards.
Is this already looking better ??
edit: colspan & rowspan not possible in css or with a trick
.c_result {
border: 1px solid red;
display: table;
width: 100%;
}
.rp-row {
display: table-row;
}
.cell {
display: table-cell;
}
<div class="c_result">
<div class="rp-row">
<ul class="cell rp-first">
<li>London</li>
</ul>
<ul class="cell rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="cell rp-result">
<li>result1</li>
<li>result2</li>
<li>result3</li>
</ul>
</div>
<div class="rp-row">
<ul class="rp-first">
<li>Paris</li>
</ul>
<ul class="cell rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="cell rp-result">
<li>result4</li>
<li>result5</li>
<li>result6</li>
</ul>
</div>
</div>
Edit:
.c_result {
width: 600px;
/* total width */
}
.c_result * {
display: block;
/* remove list items and so..*/
text-align: center;
/*center text*/
padding: 0;
/* reset */
margin: 0;
/* reset */
}
li {
outline: 1px solid black;
/*border is calculated in element width, outline not.*/
}
.rp-row > * {
float: right; /*floats bases to right*/
}
.rp-first {
width: 12.5%;
/* 1/8 width */
}
.rp-first li {
line-height: 198px;
/* base = floor ( 200 / 3 (max split) ) * 3 (max split) = 198 */
}
.rp-second {
width: 25%;
/* 2/8 width */
}
.rp-second li {
line-height: 99px;
/* base / 2 = 99; */
}
.rp-result {
width: 62.5%;
/* 6/8 width */
}
.rp-result li {
line-height: 66px;
/* base / 3 = 66; */
}
<div class="c_result">
<div class="rp-row">
<ul class="rp-first">
<li>London</li>
</ul>
<ul class="rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="rp-result">
<li>result1</li>
<li>result2</li>
<li>result3</li>
</ul>
</div>
<div class="rp-row">
<ul class="rp-first">
<li>Paris</li>
</ul>
<ul class="rp-second">
<li>Male</li>
<li>Female</li>
</ul>
<ul class="rp-result">
<li>result4</li>
<li>result5</li>
<li>result6</li>
</ul>
</div>
</div>
I am wondering how to center elements within a div but keep the text left aligned.
Here is a jfiddle of what I have so far. I want the text to be in the middle of the div but to maintain its left justification.
http://jsfiddle.net/MgcDU/5994/
HTML:
<div class="span4" id="middleFooter">
<div class="mcont" >
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<div class="mrow"> <li class="tcell">Contact Us</li> </div>
<div class="mrow"> <li class="tcell">About Us</li> </div>
<div class="mrow"> <li class="tcell">Copyright Information</li> </div>
<div class="mrow"> <li class="tcell">Terms & Conditions</li> </div>
</ul>
</div>
</div>
CSS:
#middleFooter {
color: #ccc2a0;
}
.mcont {
background-color: blue;
}
.mrow li {
background-color: red;
margin-left: auto;
margin-right: auto;
}
.mrow h5 {
display: table-row;
background-color: yellow;
}
.tcell {
display: table-cell;
}
You can try something like this - http://jsfiddle.net/GxgrL/
html:
<div class="span4" id="middleFooter">
<div class="mcont" >
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<li class="tcell">Contact Us</li>
<li class="tcell">About Us</li>
<li class="tcell">Copyright Information</li>
<li class="tcell">Terms & Conditions</li>
</ul>
</div>
</div>
css:
#middleFooter {
color: #ccc2a0;
}
.mcont {
background-color: blue;
}
li {
background-color: red;
display: block;
text-align: center;
}
li a {
background-color: green;
display: inline-block;
margin: 0 auto;
width: 170px;
text-align: left;
}
.mrow {
text-align: center;
}
.mrow h5 {
display: inline-block;
background-color: yellow;
text-align: left;
width: 170px;
}
You can get this effect by making the container div 50% width then floating it to the right. So in your fiddle add:
.mcont {
width: 50%;
float: right;
}
If you want to keep the blue background you'll need to wrap all the .mrow divs in a wrapper and apply the styles above so like:
<div class="mcont" >
<div class="wrapper">
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<div class="mrow"> <li class="tcell">Contact Us</li> </div>
<div class="mrow"> <li class="tcell">About Us</li> </div>
<div class="mrow"> <li class="tcell">Copyright Information</li> </div>
<div class="mrow"> <li class="tcell">Terms & Conditions</li> </div>
</ul>
</div>
</div>
Then:
.wrapper {
width: 50%;
float: right;
}
Just assign your .mrow divs a width and give them margin:0px auto and they will be center aligned.
.mrow{
width:20%;
margin:0px auto;
}
Here's an example of your fiddle with that style added: http://jsfiddle.net/HcQcn/