bootstrap- how to change nav tab active to underline? - css

I am using bootstrap active tab pane and currently it looks like this:
I want to make it look like this:
where the active tab is underline yellow.
My nav tab:
<p>DASHBOARD</p>
<!-- Nav tabs -->
<ul class="nav nav-tabs justify-content-center" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="login-tab" data-toggle="tab" href="#login" role="tab" aria-controls="login" aria-selected="true">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" id="sign-up-tab" data-toggle="tab" href="#sign-up" role="tab" aria-controls="sign-up" aria-selected="false">Sign-up</a>
</li>
</ul>
</div>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="login" role="tabpanel" aria-labelledby="login-tab">
<div class="card-body" style="background-color:#ffff; min-height:100%; border-radius:20px;">
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-row mb-2">
<div class="input-group col-12">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-user"></i></span>
</div>
<input class="form-control #error('email') is-invalid #enderror" type="email" name="email" id="email" placeholder="Your email address">
</div>
<div class="col-12">
#error('email')
<span class="text-danger mt-1" role="alert">
{{ $message }}
</span>
#enderror
</div>
</div>
<div class="form-row mb-2">
<div class="input-group col-12">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-key"></i></span>
</div>
<input class="form-control" type="password" name="password" id="password" placeholder="Your password">
</div>
</div>
<div class="row">
<div class="col-5 mb-1">
<div class="form-check">
<input class="form-check-input remember-check" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label text-dark" style="padding-top: 1px;" for="remember">
Remember me
</label>
</div>
</div>
<div class="col-6 text-right mb-1">
#if (Route::has('password.request'))
Forgot Password?
#endif
</div>
</div>
<div class="row">
<div class="col-12 text-center mb-1">
<button type="submit" class="btn login-btn">Login</button>
</div>
</div>
<div class="row mt-1">
<div class="col-5 offset-3">
<p class="text-dark">By signing in, you agree to the
terms and conditions.
</p>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane" id="sign-up" role="tabpanel" aria-labelledby="sign-up-tab">Register form</div>
</div>
Right now, the tabs are in a white color along with the borders but I would like to override the styling so when I switch tabs, the active tabs has the underline border-bottom.
How do I overwrite the styling ?

You should not mess/overwrite frameworks own css, just simply add a custom css class on every .tab-pane div, for example: .custom-tab and add some css in your css file like this
.custom-tab.active {
background: transparent !important;
color: white !important;
border-bottom: 2px solid yellow !important;
border-radius: 0px !important;
}

Related

bootstrap 4 tabs with buttons with active class not working

i have a small issue concerning my bootstrap 4 tabs:
My intention is too switch between buttons like this example: https://codepen.io/anon/pen/vwQamK but with bootstrap.
<div id="tab" class="btn-group btn-group-justified" data-toggle="buttons">
<a href="#prices" class="btn btn-primary active" data-toggle="tab">
<input type="radio" />Prices
</a>
<a href="#features" class="btn btn-default" data-toggle="tab">
<input type="radio" />Features
</a>
</div>
<div class="tab-content">
<div class="tab-pane active" id="prices">Prices content</div>
<div class="tab-pane" id="features">Features Content</div>
</div>
Currently the toggle between the tab content is not working!
Here is my codepen:
https://codepen.io/user1010/pen/mYQvVo
With .nav-pills
You can use .nav-pills: https://getbootstrap.com/docs/4.3/components/navs/#pills
<div class="container">
<div class="nav nav-pills">
<a href="#prices" class="nav-link active" data-toggle="pill">
Prices
</a>
<a href="#features" class="nav-link" data-toggle="pill">
Features
</a>
</div>
<div class="tab-content">
<div class="tab-pane active" id="prices">Prices content</div>
<div class="tab-pane" id="features">Features Content</div>
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/dxzaufho/12/
With btn-group and custom styles
<div class="container">
<div class="nav btn-group">
<a href="#prices" class="btn active" data-toggle="tab">
Prices
</a>
<a href="#features" class="btn" data-toggle="tab">
Features
</a>
</div>
<div class="tab-content">
<div class="tab-pane active" id="prices">Prices content</div>
<div class="tab-pane" id="features">Features Content</div>
</div>
</div>
.btn-group.nav {
display: inline-flex;
}
.btn-group .btn.active {
background-color: var(--primary);
color: #fff;
}
demo: https://jsfiddle.net/davidliang2008/dxzaufho/19/
Regarding to your issue that your tab is not working, I've opened an issue in Github. Currently it looks like you need to have either .nav or .list-group as the tab's parent class, otherwise the tab won't work properly.
It looks like instead of being inputs that you can just use the text and it switches between content.
<div id="tab" class="btn-group btn-group-justified" data-toggle="buttons">
<a href="#prices" class="btn btn-primary active" data-toggle="tab">
Prices
</a>
<a href="#features" class="btn btn-default" data-toggle="tab">
Features
</a>
</div>
<div class="tab-content">
<div class="tab-pane active" id="prices">Prices content</div>
<div class="tab-pane" id="features">Features Content</div>
</div>
Bootstrap 4.3.1 working tabs as radio buttons - jsfiddle
$(document).ready(function () {
$('input[name="intervaltype"]').click(function () {
$(this).tab('show');
$(this).removeClass('active');
});
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="nav nav-tabs" role="tablist">
<div>
<input id="optDaily" checked name="intervaltype" type="radio" data-target="#scheduleDaily">
<label for="optDaily">Daily</label>
</div>
<div>
<input id="optWeekly" name="intervaltype" type="radio" data-target="#scheduleWeekly">
<label for="optWeekly">Weekly</label>
</div>
<div>
<input id="optMonthly" name="intervaltype" type="radio" data-target="#scheduleMonthly">
<label for="optMonthly">Monthly</label>
</div>
</div>
<div class="tab-content">
<div id="scheduleDaily" class="tab-pane active">Daily</div>
<div id="scheduleWeekly" class="tab-pane">Weekly</div>
<div id="scheduleMonthly" class="tab-pane">Montly</div>
</div>
I have the same problem. The group buttons worked very well on 4.31 but after I did an upgrade on bootstrap 4.4 or 4.4.1, on refresh they get active all and only after clicking each button they start to work properly.
I suggest you to try to use bootstrap 4.3.1 with the example from #Yevgeniy Afanasyev

Attaching a dropdown to text input using Bulma

I'm coming from Semantic UI and I'm trying to do the same as this
So here is my code for Bulma
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="Find domain">
</div>
<div class="control">
<div class="select">
<select>
<option>.com</option>
<option>.edu</option>
</select>
</div>
</div>
</div>
and it looks like this
I was wondering if anyone knows how can I style the dropdown to be like semantic's ui? Is there a way in Bulma to change the icon for select input and the background or I have to write my own css?
You can use bulma dropdown along with input
<div class="dropdown is-active">
<div class="dropdown-trigger">
<div class="field">
<p class="control is-expanded has-icons-right">
<input class="input" type="search" placeholder="Search..."/>
<span class="icon is-small is-right"><i class="fas fa-search"></i></span>
</p>
</div>
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
Dropdown item
Other dropdown item
<hr class="dropdown-divider">
With a divider
</div>
</div>
</div>
You can change the background by adding a color helper (e.g. has-background-light) to the select tag.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="Find domain">
</div>
<div class="control ">
<div class="select ">
<select class="has-background-light">
<option>.com</option>
<option>.edu</option>
</select>
</div>
</div>
</div>
You'd have to write your own css for the icon.

Bootstrap align tab-content accordingly

i have following tabs,
see codepen
<div class="container-fluid">
<div class="row">
<div class="col-xs-4">
<div class="halter">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"><li><a id="hideshow" href="#" role="tab" data-toggle="tab">hide/show</a></li>
<li role="presentation" class="active"><a id="tab1" href="#home" aria-controls="home" role="tab" data-toggle="tab">Default</a></li>
<li role="presentation">Placeholder</li>
<li role="presentation">Required</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Assword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Bassword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="messages">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Cassword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-8">
<form class="form-horizontal">
<div id="l2">
</div>
</form>
</div>
</div>
</div>
How can i make the tab-content fit rightly into the bordered div?
i need somehow to maintain a smilar structure since i use some plugin.
i have no clue why stackoverflow still aks me for additional details since the executing code in a fidle is selfexplaining.
thanks for your help!!
You could use keyword row at your form-groups, and it will fit in border, you can read more about grids on bootstrap. Append a class row to every form-group of content like this:
<div class="row form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Assword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div>
</div>
Example:
.nav-tabs > li {
float:none;
display:inline-block;
zoom:1;
}
.nav-tabs {
text-align:center;
}
.nav-tabs {
border-bottom: none;
}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:focus, .nav-tabs > li.active > a:hover {border-bottom:5px solid green;}
.halter{margin:5px;padding:5px;border:1px solid gray;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet prefetch" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="halter">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"><li><a id="hideshow" href="#" role="tab" data-toggle="tab">hide/show</a></li>
<li role="presentation" class="active"><a id="tab1" href="#home" aria-controls="home" role="tab" data-toggle="tab">Default</a></li>
<li role="presentation">Placeholder</li>
<li role="presentation">Required</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 control-label">Assword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 control-label">Bassword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="messages">
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 control-label">Cassword</label>
<div class="col-sm-10">
<input type="password" class="form-control" placeholder="Password">
</div></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-8">
<form class="form-horizontal">
<div id="l2">
</div>
</form>
</div>
</div>
</div>

Bootstrap grid system works strangely

This is my code :
<div id="loginbox" class="mainbox col-md-6 col-md-offset-3 ">
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Sign In</div>
<div class="forget">Forgot password?</div>
</div>
<div class="panel-body" >
<div id="login-alert" class="alert alert-danger col-sm-12"></div>
<form id="loginform" class="form-horizontal" role="form">
<!-- id / pw -->
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username or email">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password">
</div>
<div class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<div class="row">
<a id="btn-login" href="#" class="btn btn-success col-xs-12"> Login</a>
<a id="btn-fblogin" href="#" class="btn btn-primary col-xs-12"><i class="icon-facebook"></i>Login with Facebook</a>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 control">
<div class="signup">
Don't have an account?
<a href="#" id="signuplink">
Sign Up Here
</a>
</div>
</div>
</div>
</form>
</div> <!-- <div style="padding-top:30px" class="panel-body" > -->
</div>
</div>
The only thing that I changed is <div id="loginbox" class="mainbox col-md-6 col-md-offset-3 ">
And here is before/after :
Before I inserted col-md-6 col-md-offset-3, the blue-shaded box looks balanced.
After I inserted col-md-6 col-md-offset-3, it looks unbalanced.
Why does it happen? I think that grid should work well(login box should be located at center" because it means `3(offset) - 6 - 3(offset)'.
Need your help.
Its because your loginbox does not have 12 columns in total as you specified 6+3(offset) =9
I would suggest this way as I dont like using offset
<div class="col-md-3 "></div>
<div id="loginbox" class="mainbox col-md-6">
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Sign In</div>
<div class="forget">Forgot password?</div>
</div>
<div class="panel-body" >
<div id="login-alert" class="alert alert-danger col-sm-12"></div>
<form id="loginform" class="form-horizontal" role="form">
<!-- id / pw -->
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username or email">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password">
</div>
<div class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<div class="row">
<a id="btn-login" href="#" class="btn btn-success col-xs-12"> Login</a>
<a id="btn-fblogin" href="#" class="btn btn-primary col-xs-12"><i class="icon-facebook"></i>Login with Facebook</a>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 control">
<div class="signup">
Don't have an account?
<a href="#" id="signuplink">
Sign Up Here
</a>
</div>
</div>
</div>
</form>
</div> <!-- <div style="padding-top:30px" class="panel-body" > -->
</div>
</div>
<div class="col-md-3 "></div>
Here's my take: giving it a fluid container and a couple extra rows to center things up:
<div class="container-fluid">
<div class="row">
<div class="brown-row col-md-8 col-md-offset-2">
<div class="row">
<div id="loginbox" class="mainbox col-md-6 col-md-offset-3 ">
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Sign In</div>
<div class="forget">Forgot password?</div>
</div>
<div class="panel-body">
<div id="login-alert" class="alert alert-danger col-sm-12"></div>
<form id="loginform" class="form-horizontal" role="form">
<!-- id / pw -->
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username or email">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password">
</div>
<div class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<div class="row">
<a id="btn-login" href="#" class="btn btn-success col-xs-12"> Login</a>
<a id="btn-fblogin" href="#" class="btn btn-primary col-xs-12"><i class="icon-facebook"></i>Login with Facebook</a>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 control">
<div class="signup">
Don't have an account?
<a href="#" id="signuplink">
Sign Up Here
</a>
</div>
</div>
</div>
</form>
</div>
<!-- <div style="padding-top:30px" class="panel-body" > -->
</div>
</div>
</div>
</div>
</div>
</div>
and css:
body {
background: #634a16;
}
.brown-row {
background: #9e7623;
}
#loginbox {
margin-top: 50px
}

Embed a search form in Bootstrap 3 panel heading

I'm attempting to embed a search form at the right side of a panel heading:
<div class="panel-heading">
<h3 class="panel-title">Results <span class="badge">6</span></h3>
<form class="form-inline pull-right" role="search" method="get" action="/tbl">
<div class="form-group">
<input type="text" name="criteria" class="form-control" value="<%= params[:criteria] if params[:criteria] %>" placeholder="<%= params[:criteria]? params[:criteria] : 'Enter search criteria (e.g. FOOBAR_%)' %>">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
Unfortunately, I'm having alignment issues:
In Safari (8.0.3):
In Firefox (35.0.1):
Is there a way to do this, preferably without custom CSS?
JSFiddle
Almost, see this fiddle
I put the heading and search box into col divs, but id have to add a little padding to he title to get it to line up with the search box
CSS:
.padFix{
padding-top:8px;
}
HTML:
<div class="panel-heading ">
<div class="row">
<div class="col-sm-6">
<h3 class="panel-title padFix">Results <span class="badge">6</span></h3></div>
<div class="col-sm-6">
<form role="search" method="get" action="/tbl">
<div class="input-group">
<input type="text" name="criteria" class="form-control" value="<%= params[:criteria] if params[:criteria] %>" placeholder="<%= params[:criteria]? params[:criteria] : 'Enter search criteria (e.g. FOOBAR_%)' %>">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
Here am sharing my answer, this might be useful
JS Fiddle
Here is the code
HTML
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left" style="padding-top: 7.5px;">
Header
</h4>
<div class="btn-group pull-right">
<input type="text" class="custom_input">
<button class="btn btn-success pull-right" style="height: 30px;">
Search
</button>
</div>
</div>
<div class="panel-body">
Content Body
</div>
<div class="panel-footer">
Content Footer
</div>
</div>
</div>
</div>
CSS
.custom_input {
padding: 4px 5px;
border: 1px solid #d3e0e9;
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
border-right: none;
height: 30px;
}
thank You :-)

Resources