Bootstrap footer links full width and two column on mobile - html

I have a footer with 7 links which i am centering on desktop. On mobile i would like these links to stack one on top of the other centered in one column, however they currently show inline in 2 rows of 3 columns and 1 now of 1.
HTML
<div class="col-md-12 pad-top text-center">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
CSS
.footer-links {
color:#ffffff;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display:inline-block;
font-family: HelveticaNeu;
}

For example you can add class to the footer that will hide it, when user will watch from mobile device. And then unhide two columns with two lists.
Maybe it's a bit clumsy solution, but it is also a relatively good solution ;)
HTML
<div class="col-lg-12 col-md-12 pad-top text-center hideBlock">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
<div class="col-xs-6 pad-top text-center unhideBlock">
<ul class="footer-links">
<li>LINK 1</li>
<li>LINK 2</li>
<li>LINK 3</li>
</ul>
</div>
<div class="col-xs-6 pad-top text-center unhideBlock">
<ul class="footer-links">
<li>LINK 4</li>
<li>LINK 5</li>
<li>LINK 6</li>
<li>LINK 7</li>
</ul>
</div>
CSS
#media (min-width: 768px){
.hideBlock {
display: block;
}
.unhideBlock {
display: none;
}
}
#media (max-width: 768px){
.hideBlock {
display: none;
}
.unhideBlock {
display: block;
}
}
But if you only need to break list into columns here is the useful >>> link

Per your comment yesterday, you've noted you want to have two columns on desktops/tablets, but one column on mobile and smaller widths.
This is fairly easy to achieve, you simply need to split the links into two separate divs.
.footer-links {
color: #ffffff;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: inline-block;
font-family: HelveticaNeu;
}
.footer-links li:not(:last-child) {
padding-bottom: 4px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-sm-6 pad-top text-center">
<ul class="footer-links">
<li>LINK 1
</li>
<li>LINK 2
</li>
<li>LINK 3
</li>
<li>LINK 4
</li>
</ul>
</div>
<div class="col-sm-6 pad-top text-center">
<ul class="footer-links">
<li>LINK 5
</li>
<li>LINK 6
</li>
<li>LINK 7
</li>
</ul>
</div>
When you run the above snippet, you'll note that all the links are arranged in a single column. When you click to run the snippet in full screen, they'll expand out to be two columns.
I also added some CSS for the line items in the unordered list to add padding to the bottom of all li tags except for the last one to account for the odd spacing you get when in a mobile view. You can play around with that to suit your needs.
While you still haven't indicated how many links you would like in each column, this should get you started.

Related

Material Design - Secondary Scroll Bar for List Component

In my project I'm using the code from google's material design website: https://material.io/components/web/catalog/lists/
It work great, however, as more list entries are added I have to scroll down to see them. The problem is that to scroll through the list, I am scrolling past my page header.
I'm asking if anyone knows how to add a 'secondary scroll bar' (I don't know what you call them) that when used only scrolls through the list.
An example of what I'm trying to achieve is here: https://stackoverflow.com/a/21998914/8625593
Thanks in advance!
Limit the height on the list container. It will cause a scroll bar to be shown or add a scroll vertical scroll bar with the property 'over-flow-y'.
For example:
#listContainer{
max-height:200px;
width:18%;
overflow:hidden;
overflow-y:scroll;
}
#container {
overflow-y:scroll
}
<div>
<h1>Headline</h1>
<div id="container">
<ul id="listContainer">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>Link 6</li>
<li>Link 7</li>
<li>Link 8</li>
<li>Link 9</li>
<li>Link 10</li>
<li>Link 11</li>
<li>Link 12</li>
<li>Link 13</li>
<li>Link 14</li>
<li>Link 15</li>
<li>Link 16</li>
<li>Link 17</li>
<li>Link 18</li>
<li>Link 19</li>
<li>Link 20</li>
</ul>
</div>
<div>Possible Summary Information</div>
</div>

hover the sidebar vertical menu display a submenu in bootstrap material design

How to make a display of three columns as one submenu while hovering each menu.
<div class="container">
<div class="row">
<div class="col-sm-4">
<ul class="vertical-nav">
<li>Link 1</li>
<li>Link 2
<ul class="sub-menu">
<li>Sub Link 1</li>
<li>Sub Link 2</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
I want to make the menu like this below image
Please see below. Hope this helps.
$('.vertical-nav li a').mouseover(function() {
$(this).parent().find('.sub-menu').show();
})
.mouseout(function() {
$(this).parent().find('.sub-menu').hide();
});
.sub-menu {
display:none;
}
.vertical-nav li, .sub-menu li {
list-style:none;
}
.column {
float:left;
width: 100px;
}
.title {
padding-bottom: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-4">
<ul class="vertical-nav">
<li>Link 1</li>
<li>Link 2
<ul class="sub-menu">
<div class='column'>
<li class='title'>Style</li>
<li>Sub Link 1</li>
<li>Sub Link 2</li>
</div>
<div class='column'>
<li class='title'>Subject</li>
<li>Sub Link 3</li>
<li>Sub Link 4</li>
</div>
<div class='column'>
<li class='title'>Medium</li>
<li>Sub Link 5</li>
<li>Sub Link 6</li>
</div>
</ul>
</li>
</ul>
</div>
</div>
</div>

break list item in two columns on small screen in bootstrap

I want to break my list items into 2 columns on small screen but it must be in one column on md screen
<div>
<ul>
<li> List Item 1 </li>
<li> List Item 2 </li>
<li> List Item 3 </li>
<li> List Item 4 </li>
</ul>
</div>
I want to break list item from item 3 and item 4 must be displayed in second column in front of item 1 on small screen
output should be
List Item 1 List item-4
List Item 2
List Item 3
Try below code
.clear-left {
clear: left
}
.clear-right {
clear: right
}
ul {
padding: 0 !important;
margin: 0 !important;
}
li {
padding: 10px;
border: 1px solid #aaa;
background: rgba(0, 0, 0, 0.07);
list-style-type: none;
}
.block-1 {
background: rgba(0, 0, 0, 0.05);
}
.block-2 {
margin-top: 20px;
background: rgba(0, 0, 0, 0.05);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container block-1">
<ul>
<li class="col-sm-12 col-md-6 clear-left">List Item 1</li>
<li class="col-sm-12 col-md-6 clear-left">List Item 2</li>
<li class="col-sm-12 col-md-6 clear-left">List Item 3</li>
<li class="col-sm-12 col-md-6 clear-right">List Item 4</li>
</ul>
</div>
<div class="container block-2">
<ul class="col-sm-12 col-md-6">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
<ul class="col-sm-12 col-md-6">
<li>List Item 4</li>
</ul>
</div>
Please try this
<ul class="row">
<li class="col-md-3 col-xs-4">
List Item 1
</li>
<li class="col-md-3 col-xs-4">
List Item 2
</li>
<li class="col-md-3 col-xs-4">
List Item 3
</li>
<li class="col-md-3 col-xs-4">
List Item 4
</li>
</ul>
Demo: http://codepen.io/anon/pen/adReKN
Use the below code:
<div class="row">
<ul class="col-md-12 col-sm-6 firstCol">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ul class="col-md-12 col-sm-6 secondCol">
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
</div>
CSS:
#media only screen and (max-width: 767px)
{
.firstCol
{
padding-right: 0;
}
.secondCol
{
list-style-type: none;
margin: auto;
padding-left: 0;
}
}

How to get adapted width for inline-table of nested lists?

This is how I'm displaying a nested list jsFiddle. As you can see the 'columns' are not aligned correctly as the content has different length. The elements - as example - should be at the right border.
Is it possible to get the width of each 'column' in a relative or fixed size? The complete list should have a 100% width.
Visibly I want to get this: https://jsfiddle.net/bsrms9ax/2/
ul {
display: inline-table;
border: 1px solid #000;
padding: 0px;
list-style: none;
}
<ul>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
<li>Longer Main Title
<ul>
<li>Long Title 1
<ul>
<li>Element 1</li>
<li>Elem 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
</ul>
I edited the code from Display nested list like a table , also a post by you.
If this is not you want, i will do as much i can to modify it and make it work.
// ADD SOME CODE
// www.Agary.info Agario server ;-)
// BEST LUCK IN YOUR CODE BRO
body>ul {
display:table;
}
li {
display: flex;
display: -webkit-inline-flex;
border: 1px solid #000;
padding: 0px;
list-style: none;
}
<html>
<!-- Added some css..-->
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
</head>
<body>
<ul>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
<li>
</li>
<li>Main Title
<ul>
<li>Title 1
<ul>
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</li>
<li>Title 2
<ul>
<li>Element 4</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>
EDIT: I see that this is not what you want, but maybe will be useful for any other user. I will try to modify it :)

How to position ":before" element used as icon in zurb foundation's Side nav?

I added a sub-menu to foundation's side nav exactly like in this example, but the icon is above the text.
My CSS:
.hasChildren:before{
content: "\25ba";
float: left
}
.hasChildren.active:before{
content: "\25bc";
}
My HTML:
<div class="large-4 medium-4 columns menu-wrapper">
<div class="panel">
<h4>Menu</h4>
<ul class="side-nav">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link drop
<ul class="side-nav">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</li>
</ul>
</div>
</div>
jQuery:
$('.side-nav li:has("ul")').children('ul').hide(); //hide submenu
$('.side-nav li:has("ul")').addClass('hasChildren'); // add class to li ul child
$('.side-nav li:has("ul")').click(function(){
$(this).toggleClass( "active" ) // add active class to clicked menu item
$(this).children('ul').slideToggle(); //toggle submenu
});
Image describing my problem
My problem on jsFiddle
Use relative positioning, like this:
.hasChildren:before{
content: "\25ba";
float: left;
position: relative;
top: 6px;
}
.hasChildren.active:before{
content: "\25bc";
}
Updated fiddle:
http://jsfiddle.net/vpoycbzb/1/