Sorry if this has been asked before, but I've looked at several other similar questions trying to incorporate the solution with little success. I have a bootstrap row with two col-md-6's. In the first column is the image, and in the second column is a list . What i would like to do is vertically center the list relative to the image.
Here is what my HTML looks like:
<div class="row ">
<div class="col-md-6">
<img class="img-responsive" src="500-by-700-image.jpg" >
</div> <!-- col-md-6 -->
<div class="col-md-6" >
<h4 style="font-size: 20px; line-height: 2; ">
My heeader:
<br>
<ul style="text-align: left; ">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</h4>
</div> <!-- col-md-6 -->
</div> <!-- row -->
Any idea on how I can accomplish this, thanks.
Looking around I managed to find this bit of code that works:
<!-- CSS -->
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}
<!-- HTML -->
<div class="row ">
<div class="col-md-6 vcenter"> <!-- NEW -->
<img class="img-responsive" src="500-by-700-image.jpg" >
</div> <!-- col-md-6 -->
<div class="col-md-6 vcenter" > <!-- NEW -->
<h4 style="font-size: 20px; line-height: 2; ">
My heeader:
<br>
<ul style="text-align: left; ">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</h4>
</div> <!-- col-md-6 -->
</div> <!-- row -->
try this. it works for me....
you must add this css to your code:
.col-md-6 ul{
height:inherit;
display: table-cell;
vertical-align:middle;
width: 100%;
}
Related
I created a row in footer and it's giving me extra unwanted space of same color as footer , in inspect it's showing of after element automatically created after creation of row.
When i try to remove it by margin top:-12rem; it gets removed but all the row's are disturbed . But it gives no response to specific id or class.
.page-footer {
/* position: relative; */
width: 100%;
background-color: black!important;
text-align: center;
min-width: 640px;
}
#frow {
min-width: 640px;
margin-top: -15rem!important;
text-align: center;
}
<div class="page-footer ">
<div class=" row " style="margin-top: -13rem;" id="frow">
<div class="col l4 s12 m4">
<h5>About CLub</h5>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</div>
<div class="col l4 s12 m4">
<h5>Memberships</h5>
<ul>
<li> Join</li>
<li> Renew</li>
<li> Benifits</li>
<li> IEEE Collaboration</li>
</ul>
</div>
<div class="col l4 s12 m4">
<h5>Grow With Us</h5>
<ul>
<li>Careers</li>
<li>About Us</li>
<li>Contact Us</li>
<li>get involved</li>
</ul>
</div>
</div>
<div style="color: white;text-align: center; ">
<p>We'll your encourage ideas and shape your future </p>
</div>
<div style="color: white;text-align: center; ">
<i class="fab fa-facebook"> </i>
<i class="fab fa-instagram"> </i>
<i class="fab fa-twitter"> </i>
</div>
</div>
Try to remove the div and try to use section as your tag .So that the class will be enclosed in section tag in.It might be useful instead of div or better still use paragraph tag it will be a lot more useful for you.
I have to include an HTML menu.
I need to edit the active page from the css menu.
include menu:
<div w3-include-html="inc/header.html"></div>
/*CSS example - but not working:*/
.main-menu a.active {
color: #0061bb;
}
<div class="mnmenu-sec">
<div class="container">
<div class="row">
<div class="col-md-12 nav-menu">
<div class="col-md-3">
<div class="logo">
<img src="img/logo.png" alt="" />
</div>
</div>
<div class="col-md-9">
<div class="menu">
<nav id="main-menu" class="main-menu">
<ul>
<li>menu 1</li>
<li>menu 2</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
I need to highlight an active page from the menu, such as changing the font color.
Can you tell me how I could do it?
.main-menu a {
color: #000;
transition: 0.3s;
}
.main-menu a:hover {
color: #0061bb;
}
<div class="mnmenu-sec">
<div class="container">
<div class="row">
<div class="col-md-12 nav-menu">
<div class="col-md-3">
<div class="logo">
<img src="img/logo.png" alt=""/>
</div>
</div>
<div class="col-md-9">
<div class="menu">
<nav id="main-menu" class="main-menu">
<ul>
<li>menu 1</li>
<li>menu 2</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
:active = when a link it is being clicked.
:hover = when the mouse cursor is over the link
If you want the :active then this css should do it:
#main-menu a:active {
color: #0061bb;
}
If you wanna color the link you currently are, than you need JavaScript to add a class like class="currentLink" then add css to it
.currentLink {
color: #0061bb;
}
i am trying to use the flex box technique in https://css-tricks.com/couple-takes-sticky-footer/ to responsively push down the footer in my page http://apple.mdsc1.com/test/
i used:-
<style>
#wrapper {flex: 1 0 auto;}
body, html {height: 100%}
body {
display: flex;
flex-direction: column;
}
</style>
but it failed. something in the ready made layout that i am using is spoiling the flex
how i make it work?
because the parent of #wrapper is not a flex element, so you need to change the rules from body to jPanelMenu-panel and add height:100% to it
body,
html {
height: 100%;
margin: 0
}
.jPanelMenu-panel {
display: flex;
flex-direction: column;
height: 100%
}
#wrapper {
flex: 1;
}
#footer-bottom {
background: lightgreen
}
<div class="jPanelMenu-panel">
<div id="wrapper">
<!-- Top Bar
================================================== -->
<div id="top-bar">
<div class="container">
<!-- Top Bar Menu -->
<div class="sixteen columns">
<ul class="top-bar-menu" style="float: right">
<li><i class="fa fa-phone"></i>00 971 2 6130700</li>
</ul>
</div>
</div>
</div>
<div class="clearfix"></div>
<!-- Header
================================================== -->
<div class="container">
<!-- Logo -->
<div class="four columns">
<div style="margin-top: 18px; margin-bottom:15px; float: left">
<h1>
<img src="images/mdsc1logo.png" alt="mdsc1">
</h1>
</div>
</div>
</div>
<!-- Navigation
================================================== -->
<div style="background-color: #292929">
<div class="container">
<div class="sixteen columns">
<i class="fa fa-bars"></i> Menu
<nav id="navigation">
<ul class="menu js-enabled arrows" id="responsive" style="margin: 0px">
<li>Home</li>
<li>About Us</li>
<li class="dropdown">
Solutions
<ul style="display: none;">
<li>Apple</li>
<li>Microsoft</li>
<!-- <li>Online Ordering</li>-->
</ul>
</li>
<li>Contact Us</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- Slider
================================================== -->
<div class="container">
<div class="sixteen columns">
<p style="font-size: 50px; margin-top: 40px">The Home Page For MDS ONE As A Whole</p>
</div>
</div>
</div>
<div id="footer-bottom">
<!-- Container -->
<div class="container">
<div class="eight columns">© Copyright 2017 by MDSC1. All Rights Reserved.</div>
</div>
<!-- Container / End -->
</div>
</div>
I want to align the left column to the left and the right column to the right while keeping them vertically aligned. I've seen several questions about this and I can get this to work if I don't include the "col-sm-6" since those items are floated it's giving me issues, I am looking for a work around but sticking to the Bootstrap layout.
<header>
<div class="container">
<div style="display:table-row;" class="row">
<div style="display:table-cell; vertical-align:middle; text-align:left;" class="col-sm-6">
Left Column Text
</div>
<div style="display:table-cell; vertical-align:middle; text-align:right;" class="col-sm-6">
<div class="list">
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
</div>
</div>
</div>
</div>
</header>
The questions is answered and the below methods do work but here is also another ready made solution: http://www.minimit.com/demos/bootstrap-3-responsive-columns-of-same-height
Here you go, you can achieve it with flex and align-items:center and keeping the bootstrap framework.
HTML
<div class="container">
<div class="row sm-flex-center">
<div class="col-sm-6">
Left Column Text
</div>
<div class="col-sm-6 pull-right">
<div class="list">
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
</div>
</div>
</div>
</div>
CSS
.flex-center {
display:flex;
align-items:center;
}
#media ( min-width:768px ) {
.sm-flex-center {
display:flex;
align-items:center;
}
}
#media ( min-width: 992px ) {
.md-flex-center {
display:flex;
align-items:center;
}
}
#media ( min-width: 1200px ) {
.lg-flex-center {
display:flex;
align-items:center;
}
}
Fiddle With Flex
If Not big fan of flex like me, use table
HTML
<div class="container">
<div class="row table-center">
<div class="col-md-6 col-sm-6 middle">
Left Column Text
</div>
<div class="col-md-6 col-sm-6 middle pull-right">
<div class="list">
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
</div>
</div>
</div>
</div>
CSS
.table-center {
display: table;
width: 100%;
height: 100%;
min-height: 100%;
}
.middle {
display: table-cell;
vertical-align: middle;
float:none;
}
Fiddle With Table
I hope you can all help :)
I have a sidebar on my website but because I don't want it going under the fold I would like to split this ten li sidebar into two 5 li sidebars with a div inbetween them showing content using Jquery. I have coded up the website so it looks good but I need the sidebars to act as one menu instead of two so only one selection can be made at a time , one current class etc. Anyone know how to do this? My mark-up is as follows:
<div id="sidebar">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
</div>
<div id="repcontent">
</div>
<div id="sidebar">
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
You just have to remove tags that commented in the following code:
<div id="sidebar">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
<!-- </div> -->
<div id="repcontent">
</div>
<!-- <div id="sidebar"> -->
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
Edited: To get three columns layout, I will use zurb-foundation CSS framework as follows:
<body>
<div id="header" class="row">
<div class="twelve columns">
Header
</div>
</div>
<div class="row">
<div id="left-sidebar" class="three columns">
<ul class="list2"><em>
<li class="current1">Bilgorajski</li>
<li>Rzeszowski</li>
<li>Kasuby</li>
<li>Mazur</li>
<li>Lubelski</li>
</em>
</ul>
</div>
<div id="repcontent" class="six columns">
Middle contents
</div>
<div id="right-sidebar" class="three columns">
<ul class="list2"><em>
<li>Powislainski</li>
<li>Podhalainski</li>
<li>Kujuwiak Oberek</li>
<li>Krakowiak</li>
<li>Szlansk</li>
</em>
</ul>
</div>
</div>
</body>
take it easy.. use
-webkit-column-count: 2;
this will splits your contents into two columns..Or if you want to display the sidebars in two sides separately then use 2 separate divisions and float:left|right; property. Or you can query for this using JQuery.
<body>
<div class="container">
<div class="sidebar1">
<ul class="nav">
<li>Link one</li>
<li>Link two</li>
<li>Link three</li>
<li>Link four</li>
</ul>
<p> </p>
<!-- end .sidebar1 --></div>
<div class="content">
<!-- end .content --></div>
<div class="sidebar2">
<!-- end .sidebar2 --></div>
<!-- end .container --></div>
</body>
css
.sidebar1 {
float: left;
width: 20%;
background-color: #93A5C4;
padding-bottom: 10px;
}
.content {
padding: 10px 0;
width: 60%;
float: left;
}
.sidebar2 {
float: left;
width: 20%;
background-color: #93A5C4;
padding: 10px 0;
}
Try this code. this may clarifies your problem .