Bootstrap navbar center with two lists - twitter-bootstrap-3

How do you get a bootstrap navbar ul to be centered, but ignore the space occupied by another ul, so that the center is truly centered, and not shifted?
I have two unordered lists in my bootstrap navbar. I want one of them (#clause) to be centered, and the other (#social-icons) to be on the right.
But what happens is the centered one is slightly to the left of absolute center because the one on the right takes up some of the space.
Thus the centering is calculated based on the remaining space, rather than the entire width
Here is my code so far:
Currently, I have the right-aligned list within the other list. They should be two separate lists. But when I separate them, I run into the problem of each of them wanting their own rows.
I am using bootstrap 3
css
#navbar {
#clause {
text-align: center;
li {
font-size: 1.6em;
float: none;
display: inline-block;
*display: inline;
*zoom:1;
vertical-align: top;
}
}
#social-icons {
}
}
navbar HTML
<nav class="navbar navbar-default navbar-fixed-top" id="navbar">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<ul class="nav nav-tabs" id="clause">
<li></li>
<li></li>
<li></li>
<ul class="nav navbar-right" id="social-icons">
<li></li>
<li></li>
</ul>
</ul>
</div>
</div>
</div>
</nav>

If you want to ignore the space occupied by the list #social-icons make its position absolute.
Doing so will give the whole width to #clause
CSS
#social-icons {
position: absolute;
right:0;
top:0;
}

Related

How do I center an element on large display using materialize?

I am using Materialize CSS and I'm trying to center a div. I'm trying to get the white boxes to center on mobile and desktop to the center of the page. All the white boxes are in the same div called root.
index.html
<body>
<div class="container">
<div id="mainContent" class="row">
<div id="root" class="col s12 xl l6"></div>
</div>
</div>
</body>
styles.css
#mainContent {
background-color: blue;
margin: auto;
display: block;
}
#root {
margin: 0 auto;
position: relative;
}
On mobile, it centers the white boxes correctly.
On desktop the boxes are on the left side.
If I add margin-left to .root{} then it's not centered on the mobile version.
I think the best way is to use grid offsets on the columns:
<body>
<div class="container">
<div id="mainContent" class="row">
<div class="col s12 l6 offset-l3"></div>
</div>
</div>
</body>
Adding the class offset-l3 will add an offset of 3 columns on the left for screen sizes l and xl. With 12 total columns and the content being 6 columns an offset of 3 will result in the content being centered.
The style.css can be updated to only set the background-color:
#mainContent {
background-color: blue;
}
I added a wrapper to index.html like so
<div id="mainContent" class="row">
<div class="valign-wrapper">
<div id="root" class="col s12 xl l6"></div>
</div>
</div>
Now the white boxes are centered in the middle on both smaller resoultion displays and bigger.

data-toggle="dropdown" colour upon click

I'm trying to understand what exactly data-toggle="dropdown" does in my nav bar and it seems that the primary purpose is for touch screen surfaces, so that when the nav link is clicked, the menu stays open unlike a menu upon hover. (Please correct me if I'm wrong) to my rudimentary knowledge it changes the link to an active link??
So based on the code below when I click on the navbar link which is publications, it stays highlighted, how do I change the color of this highlight?
What line of CSS in bootstrap do I edit?
Thanks!
Update:
Using
.dropdown-toggle:focus {color:red;text-decoration: none;}
on its own doesn't work, I have to add '!important' to the line otherwise it doesn't take effect, maybe conflict with the bootstrap code? Also, what I'm actually looking to do is not the text colour but the background colour. using background:color doesn't work at all for me.
<li class="dropdown">
Publications
<ul class="dropdown-menu">
<li>Submissions</li>
<li>News</li>
<li>Code of Conduct</li>
<li>Useful Links</li>
</ul>
</li>
I assume, if you are looking for color to stay till your dropdown is open, you should use pseudo focus
.dropdown-toggle:focus {
color:red;
text-decoration: none;
}
And if you are looking to change on hover, you can do it using the below code.
.dropdown-toggle:hover{
color: green;
text-decoration: none;
}
You can see in the below example.
On hover it's green and on focus it's red
.dropdown-toggle:focus {
color: red;
text-decoration: none;
}
.dropdown-toggle:hover {
color: green;
text-decoration: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<li class="dropdown">
Publications
<ul class="dropdown-menu">
<li>Submissions</li>
<li>News</li>
<li>Code of Conduct</li>
<li>Useful Links</li>
</ul>
</li>

Bootstrap Jumbotron

I have added a jumbotron to my webpage, my page is now displaying the bottom and right scroll bar! Not sure how to resolve this.
Any tip's or pointers much appreciated.
url http://tyrescanner.net/contact-us
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<h1><span style="color: #ffffff;">Welcome to Tyrescanner</span></h1>
<p></p>
<h2>Contact us.</h2>
</div>
</div>
</div>
</div>
what are you asking for? I assume you just don't want bottom scrollbar ,is that right?
If so, below is your CSS for HTML . change that as below it's in your bootstrap.css file and line number 1071
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
overflow: auto;
overflow-x: hidden;
}
Your jumbotron is wrapped with divs row and col-md-12:
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
Delete them and leave only jumbotron.
or remove paddings from your css:
.container-fluid {
width: 100%;
padding-top: 0px;
/* padding-left: 0px; */
/* padding-right: 0px; */
padding-bottom: 0px;
}
It overwrites bootstrap css and cause problem with page width.
After viewing your site I see some issues:
You're using a container-fluid and a nested container-fluid as the jumbotron parent element, the nested one is redundant.
Then I see you've overridden container-fluid and .col--12 classes default bootstrap left/right padding to 0px but you didn't change the default margin of the .row class to have 0px left/right margin hence your bottom scroll bar.
For the footer, remove the margin-top and make the footer a direct child of the body element then add the following css to the form, body and html elements: height:100%;, the rest is margins that you added to the elements.

Bootstrap tooltip opens and closes repeatedly

I have a bootstrap tooltip which I have custom styled. There seems to be an issue with it. Whenever we hover over it, it opens and then immediately closes.
HTML -
<div class="container" style="padding-top:300px">
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" data-html="true" title="" data-original-title="Tooltip Text">i</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" data-html="true" title="" data-original-title="Tooltip Text">i</span>
</div>
</div>
Here's an inline link to jsFiddle
UPDATED
I made a few changes. Try this: https://jsfiddle.net/2h7jbt9n/6/
HTML
<div class="container" style="padding-top:30px">
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" title="YoHo Ho Ho" data-placement="top" data-toggle="tooltip">i</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" title="YoHo Ho Ho" data-placement="top" data-toggle="tooltip">i</span>
</div>
</div>
JS
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip({
container: '.info-circle'
});
});
The issue was with padding for the info-circle. I wrapped it in a container. It doesn't flicker now.
Hope it helps.
You are no longer using the tooltip-arrow as the visual arrow you are using the :before and :after after as the visual arrow. The problem is that you have made the arrow bigger and made your own triangles. When you make your css arrow you are using borders. You have set your top border colors to white and blue to make it seem like the arrow has a border as well. In doing this you have forgotten that your arrow still has a bottom transparent border and this transparent border is covering up the element that you are hovering over to deploy the tooltip. So set your :before and :after psuedo elements for your .tooltip-arrow to have a bottom border of none. Like so:
.tooltip.top .tooltip-arrow:after {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -17px;
top: -5px;
border-width: 12px;
border-top-color: #003f6e;
border-bottom:none;
}
.tooltip.top .tooltip-arrow:before {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -15px;
top: -5px;
border-width: 10px 10px 0;
border-top-color: #fff;
border-bottom:none;
z-index: 1;
}

Bootstrap 3 Carousel full screen flicker

I'm a beginner for web front-end design, using bootstrap to make a project prototype.
I want to do a product like this website
The features I want is
* expand carousel to full screen when visiting the website and then can scroll down to another div element.
I found this similar solution, but unfortunately it uses Carousel as the whole background.
To get the effect I want, I check the javascript src code and edit it.
modify this line (Shown on JSFIDDLE line 13 )
$('.carousel .item').css({'position': 'fixed', 'width': '100%', 'height': '100%'});
into this line (Shown on JSFIDDLE line 13 )
$('.carousel .item').css({'position': 'relative', 'width': $(window).outerWidth(), 'height': $(window).outerHeight()});
Yep, finally get the effect I want!! However, when the photo transition, a unexpected flicker appear, seems the photo is not at right location at first, then go to its right place immediately.
It's annoying when I see the content inside div below, like 1info or 2info.
here is the jsfiddle demo example for the issue.
I tried to use the solution like set z-index, but fail...
Can someone help me to solve this annoying problem? Thanks a lot!!
Here's a flicker-free version without any plugins:
HTML:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div id="slide1" class="fill">
<div class=" carousel-caption">
<h1>1</h1>
</div>
</div>
</div>
<div class="item">
<div id="slide2" class="fill">
<div class=" carousel-caption" >
<h1>2</h1>
</div>
</div>
</div>
<div class="item">
<div id="slide3" class="fill">
<div class=" carousel-caption" >
<h1>3</h1>
</div>
</div>
</div>
</div>
</div>
CSS:
html, body {
height: 100%;
}
.carousel, .item, .active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
.fill {
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
}
#slide1 {
background-image: url('http://stylonica.com/wp-content/uploads/2014/03/Cute-Dog-Wallpaper.jpg');
}
#slide2 {
background-image: url('http://hdwallimg.com/wp-content/uploads/2014/02/White-Dog-Running-Wallpaper-HD.jpg');
}
#slide3 {
background-image: url('http://www.petfinder.com/wp-content/uploads/2012/11/122163343-conditioning-dog-loud-noises-632x475.jpg');
}
No additional javascript required, just make sure that the jquery and bootstrap.js files are linked in your page.