Bootstrap 3 accordion - expand collapse icons beside panel title - twitter-bootstrap-3

I want this simple Bootstrap 3 accordion:
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon
</div>
</div>
</div>
</div>
to have an plus icon when in closed and a minus icon when in hover and active.
My css:
.panel-title a {
background: url('plus.png') no-repeat 100% 50% ;
padding-right:20px;}
.panel-title a:hover{
background: url('minus.png') no-repeat 100% 50% ; }
.panel-title a:active {
background: url('minus.png') no-repeat 100% 50% ; }
So far is working except the active state. Can you help me to make it work?
Thank you

If I recall correctly, the :active state only occurs while the link is actually be clicked. :active has nothing to do with the state of the collapse.
To get this to work, I would change your CSS to something like this:
.panel-title a {
background: url('plus.png') no-repeat 100% 50% ;
padding-right:20px;}
.panel-title a:hover{
background: url('minus.png') no-repeat 100% 50% ; }
.panel-title a.active {
background: url('minus.png') no-repeat 100% 50% ; }
Note that instead of using the :active pseudo, we are actually going to use a class called .active.
Now, just toggle the class on and off via javascript. There are a couple of ways to do this, but the most straight forward would be to attach a listener to the existing a tag, like so:
$('[data-toggle]').on('click', function() {
$(this).toggleClass('active');
});
So in summary, change :active to .active in your css, and add three lines of javascript.
See http://www.bootply.com/130209 for a working example.

Related

Left fixed sidebar with animated left sidebar in vuejs

im developing first vuejs application with bootstrap vue and actually im stuck on one thing. My master page contains left fixed sticky sidebar where i have two icons as menu link. The goal is when i click on any menu link i need the left sidebar to pop up (animation from left to right). Something like submenu with 100% height and custom width.
For the left fixed sidebar I used whole bootstrap grid system. Now im trying to implement bootstrap sidebar which will be animated with offset left margin so that it starts from the right edge of the fixed sidebar. The problem what i have now is that the animation goes through the fixed sidebar.
How to achieve this? Should i used sidebar component from bootstrap vue or implement pure html div element and control its animation? Should i play with z-index?
MasterView.vue
<template>
<b-row class="h-100 m-0">
<Menubar msg=""></Menubar>
<b-col id="content">
<router-view />
</b-col>
</b-row>
</template>
<script>
import Menubar from '#/components/Menubar.vue'
export default {
name: 'master',
components: {
Menubar
}
}
</script>
Menubar.vue
<template>
<b-col id="menubar" class="align-self-center"
>{{ msg }}
<div :class="[currentPage.includes('sms-template') ? activeClass : '', 'text-center py-3']">
<b-button variant="link" v-b-toggle.sidebar-footer>
<feather type="message-square" class="menu-icons"></feather>
</b-button>
<b-sidebar id="sidebar-footer" aria-label="Sidebar with custom footer" no-header>
<template v-slot:footer="{ hide }">
<div class="d-flex bg-dark text-light align-items-center px-3 py-2">
<strong class="mr-auto">Footer</strong>
<b-button size="sm" #click="hide">Close</b-button>
</div>
</template>
<div class="px-3 py-2">
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac
consectetur ac, vestibulum at eros.
</p>
</div>
</b-sidebar>
</div>
</b-col>
</template>
<script>
export default {
name: 'Menubar',
props: {
msg: String
},
data() {
return {
activeClass: 'menu-active'
}
}
}
</script>
App.vue (css)
<style>
#import '../node_modules/roboto-fontface/css/roboto/roboto-fontface.css';
* {
outline-style: none;
}
html,
body,
.tooltip-inner {
font-family: 'Roboto';
/*font-size: 0.87em;*/
font-size: 0.875rem;
font-weight: 400;
}
#menubar {
-ms-flex: 0 0 80px;
flex: 0 0 80px;
padding: 0;
z-index: 1000px;
}
#content {
background-color: #f5f5f5;
}
/* Icon links behavior */
.menu-icons {
width: 20px;
height: 20px;
vertical-align: middle;
}
.menu-active {
background-color: #f5f5f5;
}
.icon-link {
color: #aab0b7;
}
.icon-link:hover {
color: #2699fb;
}
.router-link-exact-active {
color: #0060a1;
}
.b-sidebar:not(.b-sidebar-right) {
left: 80px;
}
.bg-light {
background-color: #fcfcfc !important;
}
.b-sidebar-outer {
z-index: 5;
}
</style>

Grid behavior Bootstrap4 vs Bootstrap3

I've noticed that something small changed between v3 and v4 I wasn't aware of.
Basically i tried to build the Answer of this Question: Twitter Bootstrap 3 rowspan and reorder
but in Bootstrap4.
The obvious solution would be to use the "float-sm-right" class, instead of the custom one "b-col".
But this is not working, instead the red col always gets pushed to the end of the blue one.
<div class="col-sm-5 float-sm-right">
http://jsfiddle.net/jr70k9L6/
So is there any way to build this in Bootsrap4, while still getting the A-B-C order for smaller-sizes than sm?
Seems somehow trivial to me, but I just cant wrap my head around this...
The answer was simple: Flex does not float.
Bootsrap4 class="row" is display: flex; so float-sm-right will not work.
If you get rid of class="row" and float all the div's inside that grid is possible in v4:
<div class="">
<div class="col-sm-7 float-left" style=" background: green; height: 300px;">
<p>A</p>
</div>
<div class="col-sm-5 float-left float-sm-right" style="background: blue; height: 600px;">
<p>B</p>
</div>
<div class="col-sm-7 float-left" style="background: red; height: 300px;">
<p>C</p>
</div>
</div>
http://jsfiddle.net/j0scL2r9/

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.

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 navbar center with two lists

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;
}