I've added a right side list group to my site using bootstrap and then I added a collapse to every list group item, all these worked successfully. I am able to add text to the list group collapse without anything bad happening. However, whenever I try to add links, the collapse just leaves the link outside of the container box where the text is enclosed in.
Here is the code to one list-group element:
<!-- Defines the collpase method !-->
<a class="list-group-item" data-toggle="collapse" href="#mapscollapse">
<!-- Glypicon added !-->
<span class="glyphicon glyphicon-menu-down pull-right vcenter"></span>
<!--Added heading as maps !-->
<h4 class="list-group-item-heading">Maps</h4>
<!--Collpase Target !-->
<div id="mapscollapse" class="collapse">
<!-- Links !-->
<ul>
<li>Google</li>
</ul>
</div>
The link to the site: http://www.tabletstudios.ca/csgo.html click on maps section to see the issue in detail.
You an not use <a> tag inside <a> that's the reason it's going out of the container. To fix this for container you need to use <div> tag instead of <a>
your structure is
<div id="homecollapse" class="collapse in" aria-expanded="true" style=""><a class="list-group-item" data-toggle="collapse" href="#homecollapse" aria-expanded="true">
</a>Visit W3Schools
</div>
update your structure as follows
<div id="homecollapse" class="collapse in" aria-expanded="true" style=""><div class="list-group-item" data-toggle="collapse" href="#homecollapse" aria-expanded="true">
Visit W3Schools
</div>
</div>
Related
I am working with bootstrap, and I have for example this code snippet :
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Start Bootstrap</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
Symptoms
<li class="divider-vertical"></li>
</li>
<li>
Services
<li class="divider-vertical"></li>
</li>
<li>
Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
I can see the navbar, navbar-inverse, navbar-fixed-top, container, navbar-header, navbar-toggle, sr-only, icon-bar,navbar-brand, collapse, navbar-collapse, nav navbar-nav, etc...
So - Lets say I want to align the list in this code to the center. Which class, of the 12+ classes, do I have to modify with text-align? Is there a way of "backtracking" through the divs to see which one to change? The class that directly contains the list is nav navbar-nav, but if I change :
.navbar-nav > li > a
to include text-align:center; , nothing happens. Which must mean that I changed the wrong class.
If you know a way of determining which class to change, I appreciate it!
Thank you.
As rsn said in a comment, the best way is to install a developer tool that comes with the browsers. I personally like the Chrome one but the Firefox one works well too. You can select an individual item on your page using the select icon (arrow pointing to a box) and see what styles are attached to it. If you're trying to change padding, look at which element on your page has the padding, and then change that class.
Add an Id to the one you want to edit. Id overrules classes making the site then use the styling of the id instead of the class.
Or edit starting with .navbar and add classes after that...
Eg: .navbar{...} or .navbar .navbar-header .navbar-brand{...}
If you want the sub-menu (symptoms, services, contact) center aligned you can just use Bootstrap's text-center helper class on the UL as follows:
<ul class="nav navbar-nav text-center">
I am trying to use the Boostrap 3 grid system. I have a navigation header that i'm trying to customize in the regular desktop screen resolution. The columns work fine until I size the screen down to about 1200px wide. Then the left two links - a button and a regular link start stacking. I don't know how to resolve this. When I change the column sizes the middle column menu links start stacking which I don't want either. I feel like I am missing something really basic here. And I am a newbie in advance so my apologies for lack of knowledge in certain areas.
The live link is here:
http://www.splashdesignstudios.com/template/template3.html
You can use the navbar bootstrap and the collapse plugin.
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img alt="Brand" src="img/mocklogo.png" style="height: 100%;">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Link1 <span class="sr-only">(current)</span></li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
<li>Link5</li>
<li>Link6</li>
<li>Link7</li>
</ul>
<form class="navbar-form navbar-right">
<span class="fa fa-sign-in"></span>Login
<button type="submit" class="btn btn-custom"><span class="fa fa-search"> </span>Sign Up</button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
You can change the appearance just by changing the bootstrap-css. You can find some themes at the bootswatch.
Check this link to see how it's working. In this example, I'm using the Paper theme.
Hope it's useful!
Specifying fixed width classes to three columns gives less width to last column once your screen size reduces. I would divide the header into two columns (both with display: table-cell and vertical-align: middle) with first one containing the logo and menu and second one containing the buttons. However, to make it act properly under 1200px, you will need to use media queries and adjust the styles for every element accordingle.
Currently I have a jumbotron setup with some paragraph text, and I would like to stick a button dropdown inline with the text.
Dropdown button
<span class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Button... <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Opt 1</li>
<li>Opt 2</li>
</ul>
</span>
Jumbotron
<div class="jumbotron">
<h1>Hello!</h1>
<p>Welcome</p>
<p>Another paragraph
<!-- dropdown is here -->
</p>
</div> <!-- jumbotron -->
If the dropdown is within the <p> tag, it does not "dropdown" (but renders). If it is outside of the <p> tag it functions fine, but I would like it to be inline with the text and need the text to be in the <p> tag to get the style. Any ideas?
Things to note -- If I replace the <span> tags with <div> tags, it will work fine within the <p> tags, but won't be inline.
Solution
Added class="pull-left" on the <p> tag to get it inline (from Esotericist's answer)
<div class="jumbotron">
<h1>Hello!</h1>
<p>Welcome</p>
<p class="pull-left">Another paragraph</p>
<!-- dropdown is here -->
</div> <!-- jumbotron -->
If you want it inline then you need to use pull-left and pull-right, see here for an example:
http://www.bootply.com/T2wgdlzhZf
Is it what you are looking for?
I've created a navigation bar with a simple contact button on the right hand side using twitter bootstrap v3.
However when the screen size is < 768px it drops outside of the navigation bar.
This is the section with the problem.
<div class="pull-right">
<ul class="nav">
<li id="myContactButton" class="nav-text alternate">Contact Us</li>
</ul>
</div>
http://jsfiddle.net/x9NBC/
I've had a look through the #media queries in the css but I can't figure out which is making it drop down like that.
How can I make it stay in line with the navigation?
Add these Sections
I have added pull-left class to some of the element, mentioning below
<div class="navbar-header pull-left">
Pull left for button
<button type="button" class="navbar-toggle pull-left" data-toggle="collapse" data-target=".navbar-collapse">
Add pull-left for anchor tag also
<a href="index.php" class="pull-left">
Here is the Demo http://jsfiddle.net/x9NBC/6/
I have designed a whole website using Twitter Bootstrap and it works very well for the most part. I have done quite a bit of CSS in the past but had never done a framework like this.
The main problem I have is that when the browser goes under 600px the and the header condenses into a dropdown (which I want) the dropdown goes behind images and some HTML elements such as text input boxes and other dropdown menus.
Is there any way to make this header dropdown menu opaque so that it is in front of every other element? I would provide some code but I am not sure specifically what part of the Twitter Bootstrap stylesheet would be helpful.
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">Exployre</a>
<div class="nav-collapse">
<ul class="nav">
<li>Find</li>
<li>Share</li>
<li>Inspire</li>
<li>Discuss</li>
<li>Groups</li>
<li>Profile</li>
<li>About</li>
<li>
<form action="/search" class="navbar-search">
<div>
<input type="text" placeholder="Search" class="search-query pull-right" name="q" size="55" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
I believe all of these classes are straight from the Twitter Bootstrap CSS without modification.
You probably have a z-index on your website content that is a higher value than the z-index defined for the Dropdowns.
If you're using the LESS version of Twitter Bootstrap, open variables.less and find the line containing #zindexDropdown (on line 144). The default setting is 1000, you can change it to a number that is higher than the z-index on your content.
If you're using the normal CSS, it is defined in the rule for .dropdown-menu (on line 2773).