I'm making a navbar using Bootstrap, which can be seen here
All links are behaving the same way except the 'Save and exit' link. What can I do to make 'Save and Exit' look the same? Don't know why it keep being blue when it's meant to be grey as the other links?
Code included below.
HAML:
%nav.navbar.navbar-fixed-top.navbar-dark.bg-inverse
= link_to image_tag("logo-builder.png"), root_path
%ul.nav.navbar-nav.pull-xs-right
%li.nav-item
%button.btn.btn-link{type: 'button', 'data-toggle' => 'modal',
'data-target' => '#explainQuestionModal'}
Explain Question
%button.btn.btn-link
Preview
%button.btn.btn-link
= link_to 'Save and exit', root_path
= render 'explain_question_modal'
HTML:
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<%= link_to image_tag("logo-builder.png"), root_path %>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<button class="btn btn-link" data-target="#explainQuestionModal" data-toggle="modal" type="button">
Explain Question
</button>
<button class="btn btn-link">
Preview
</button>
<button class="btn btn-link">
<%= link_to 'Save and exit', root_path %>
</button>
</li>
</ul>
</nav>
<%= render 'explain_question_modal' %>
CSS:
.btn-link {
color:grey !important;
font-size:0.9em;
}
.btn-link:hover {
color:white;
}
.btn-link:focus {
color:white;
}
Because you are styling a button with class .btn-link but "save and exit" has a a link as child of that button which is wrapping the text "Save and Exit"
so you need to add .btn-link a {color:grey} to apply the color to the link
Note: I fixed the :hover to work with a as well
Snippet
.btn-link {
color: grey;
font-size: 0.9em;
}
/*added*/
.btn-link a {
color: grey;
text-decoration:none;
display:block
}
.btn-link:hover, .btn-link:hover a {
color:white;
}
.btn-link:focus, .btn-link:focus a {
color:white;
}
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<a href="#">
<img src="//lorempixel.com/100/100" />
</a>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<button class="btn btn-link" data-target="#explainQuestionModal" data-toggle="modal" type="button">
Explain Question
</button>
<button class="btn btn-link">
Preview
</button>
<button class="btn btn-link">
Save and exit
</button>
</li>
</ul>
</nav>
As an alternative, you don't necessarily have to use buttons, you can just use a tags for simplification.
Working example Snippet
.nav-item .nav-link {
color: grey;
outline: none;
}
.nav-item .nav-link:hover,
.nav-item .nav-link:focus {
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<a class="nav-link" data-toggle="modal" href="#explainQuestionModal">Explain Question</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/">Preview</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/">Save and Edit</a>
</li>
</ul>
</nav>
<div class="modal fade" id="explainQuestionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Title</h4>
</div>
<div class="modal-body">
Body
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
HAML Example
%nav.navbar.navbar-fixed-top.navbar-dark.bg-inverse
%a.navbar-brand{:href => "#"} Brand
%ul.nav.navbar-nav.pull-xs-right
%li.nav-item
%a.nav-link{'data-toggle' => 'modal', 'data-target' => '#explainQuestionModal'}
Explain Question
%li.nav-item
%a.nav-link{:href => "/preview"}
Preview
%li.nav-item
%a.nav-link{:href => "/save"}
Save and Edit
.modal.fade#explainQuestionModal(tabindex="-1" role="dialog" aria-labelledby="explainQuestionModal" aria-hidden="true")
.modal-dialog(role="document")
.modal-content
.modal-header
%button.close(type="button" data-dismiss="modal" aria-label="Close")
%span(aria-hidden="true") ×
%h4.modal-title#explainQuestionModal Title
.modal-body
%p Body
.modal-footer
%button.btn.btn-secondary(type="button" data-dismiss="modal") Close
%button.btn.btn-primary(type="button") Save changes
Related
Bootstrap Jumbotrons go out of the container on my website which means the navbar on the mobile version does not fill the screen. Other pages where I don't have a jumbotron this problem does not occur.
I tried using a Card instead, but that has some problems when I put it anything other than text
<div class="row">
<div class="jumbotron col-lg-8 col-md-12"
style='margin-left: 15px; margin-top: 15px; padding-top: 10px; padding-bottom: 10px; margin-bottom: 10px;'>
<h1 class="display-3">
<b>Welcome to SkyWars.fun</b>
</h1>
<p class="lead">We focus on updating regularly, and we listen close to
our community suggestions.</p>
<hr class="my-4">
<p>We have a perk system, comparable with kits or abillities. Any
player can enable 3 perks at once. These perks give small advantages
for your gameplay. Choose wisely, and adapt with your perks! Happy
SkyWars! And have fun!</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="../tips" role="button">Tips
and tricks</a>
</p>
</div>
</div>
and for the navbar
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" role="navigation">
<a class="navbar-brand" href="../">IP: SkyWars.fun</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarColor01" aria-controls="navbarColor01"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li
class="nav-item <?php if($_SERVER['REQUEST_URI'] === '/') echo 'active' ?>"><a
class="nav-link" href="https://www.skywars.fun/" title="Go to the main page">Home </a></li>
<li class="nav-item <?php if(isPage('/about/')) echo 'active' ?>"><a
class="nav-link" href="https://www.skywars.fun/about" title="Information about SkyWars.fun">About</a></li>
<li class="nav-item <?php if(isPage('/tips/')) echo 'active' ?>"><a
class="nav-link" href="https://www.skywars.fun/tips" title="Tips and Tricks">Tips</a></li>
<li class="nav-item <?php if(isPage('/donate/')) echo 'active' ?>"><a
class="nav-link" href="https://www.skywars.fun/donate" title="Donate">Donate</a></li>
<li class="nav-item <?php if(isPage('/search/')) echo 'active' ?>"><a
class="nav-link" href="https://www.skywars.fun/search" title="Leaderboard">Leaderboard</a></li>
</ul>
<form class="form-inline my-2 my-lg-0" action="../search" title="Lookup player">
<input class="form-control mr-sm-2" type="text" name="player"
placeholder="Search player">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Images of the problem
https://drive.google.com/file/d/0ByAYcnq6pPDmNlJsUUNBbkM1aFRITEQ5TUF4U0JxWXpOYVBV/view?usp=sharing
https://drive.google.com/file/d/0ByAYcnq6pPDmcnVsbTNMbkI2MnlNdmZocmtXV0FWbXpmUTdN/view?usp=sharing
* {
margin: 0;
padding: 0;
}
.banner {
background: #e9ecef;
}
#media only screen and (max-width: 767px) {
.display-3 {
font-size: 2rem !important;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" role="navigation">
<a class="navbar-brand" href="../">IP: SkyWars.fun</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarColor01" aria-controls="navbarColor01"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li
class="nav-item <?php if($_SERVER['REQUEST_URI'] === '/') echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/" title="Go to the main page">Home </a></li>
<li class="nav-item <?php if(isPage('/about/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/about" title="Information about SkyWars.fun">About</a></li>
<li class="nav-item <?php if(isPage('/tips/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/tips" title="Tips and Tricks">Tips</a></li>
<li class="nav-item <?php if(isPage('/donate/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/donate" title="Donate">Donate</a></li>
<li class="nav-item <?php if(isPage('/search/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/search" title="Leaderboard">Leaderboard</a></li>
</ul>
<form class="form-inline my-2 my-lg-0" action="../search" title="Lookup player">
<input class="form-control mr-sm-2" type="text" name="player"
placeholder="Search player">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<section class="banner">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="jumbotron">
<h1 class="display-3">
<b>Welcome to SkyWars.fun</b>
</h1>
<p class="lead">We focus on updating regularly, and we listen close to
our community suggestions.
</p>
<hr class="my-4">
<p>We have a perk system, comparable with kits or abillities. Any
player can enable 3 perks at once. These perks give small advantages
for your gameplay. Choose wisely, and adapt with your perks! Happy
SkyWars! And have fun!
</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="../tips" role="button">Tips
and tricks</a>
</p>
</div>
</div>
</div>
</div>
</section>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
I have reduced font-size for small devices, it was getting out of the container. Also use .container > .row > .col-lg-12 [just for example] before using the main class. For reference go through https://getbootstrap.com/docs/4.1/layout/grid/ this link. Hope it'll solve your problem
I have a header with a logo a dropdown menu and a search bar the problem is that dropdown button it's down and I want it to up.
I have this way:
But I want something like this where button is align with the logo and search bar:
I have tried a lot of things like call the class of button in css and put margin-button with a lot of pxls but its work, any suggestion?
This is my code HTMl where I have the button:
<header>
<nav class="navbar navbar-default navbar-custom" role="navigation">
<div class="container">
<a class="navbar-left" href="#"><img src="assets/img/logo-01.png" style="max-width:70px"/></a>
<div class="navbar-header navbar-left">
<button type ="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapse-1">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
<div class="cd-dropdown-wrapper">
<button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle cd-dropdown-trigger">Categorias</button>
<nav class="cd-dropdown">
Close
<ul class="cd-dropdown-content">
<li class="has-children">
Eletrodomésticos
<ul class="cd-secondary-dropdown is-hidden">
<li class="go-back">Menu</li>
<li class="see-all">Todos os eletrodomésticos</li>
<li class="has-children">
Eletrodomésticos
<ul class="is-hidden">
<li class="go-back">Eletrodomésticos</li>
<li class="see-all">Todos os eletrodomésticos</li>
<!--<li class="has-children">-->
<li>Grandes Eletro de cozinha</li>
....<!--(has other categories but it doesnt matter for here so I skip that part)-->
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Pesquisar Produto">
</div>
<button type="submit" class="btn btn-danger">
<i class="glyphicon glyphicon-search"></i>
</button>
</form>
</div>
</div>
</div>
</nav>
</header>
This is my css code:
.btn-default {
margin-bottom: 350px;
background: #25727D;
border-color: #25727D;
position: absolute;
margin-left: 50px;
}
.btn-default {
margin-bottom:350px;
background: #25727D;
border-color: #25727D;
position:absolute;
margin-left:50px;
}
Since .btn-default already have position:absolute, just change top:10px or top:desiredValue accordingly to change vertical position of button.
I am in charge of getting the mobile navigation on the site to work as intended but I have come into a bit of a problem.
This is a link to my code, the thing is that it looks how I want it too and the functionality is kind of there what I want it to do is when it drops down that the navigation bar takes up 100% of the screen rather than activating the scroll bar.
I have already tried using the code: overflow: hidden; and overflow-y: hidden; Neither of these have worked. if the link has expired some code is provided below.
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal">×</button>
<h4 class="modal-title">Session Timeout</h4>
</div>
<div class="modal-body">
<p>
<label>Your session has not been refreshed for 20 minutes, you will be logged out after 30 seconds. If you wish to continue working click the button below.</label>
</p>
</div>
<div class="modal-footer">
<asp:button class="btn btn-default" id="Button1" data-dismiss="modal" onclientclick="stopTimer('<%= FinalTimer.ClientID %>')" text="Continue Working" runat="server">
</asp:button></div>
</div>
</div>
</div>
<div class="navbar navbar-inverse navbar-fixed-top">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-target=".navbar-collapse" data-toggle="collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<div id="MainMenu">
<div class="list-group panel">
<a class="list-group-item list-group-item-success" href="#demo3" data-toggle="collapse" data-parent="#MainMenu">Admin</a>
<div class="collapse" id="demo3">
<a class="list-group-item1" href="#SubMenu1" data-toggle="collapse" data-parent="#SubMenu1">Placements<i class="fa fa-caret-down"></i></a>
<div class="collapse list-group-submenu" id="SubMenu1">
<a class="list-group-item2" href="#" data-parent="#SubMenu1">New placement</a>
<a class="list-group-item2" href="#" data-parent="#SubMenu1">End Placement</a>
<a class="list-group-item2" href="#" data-parent="#SubMenu1">New Referal</a>
<a class="list-group-item2" href="#" data-parent="#SubMenu1">End Referal</a>
</div>
<a class="list-group-item1" href="#SubMenu2" data-toggle="collapse" data-parent="#SubMenu2">Appliences<i class="fa fa-caret-down"></i></a>
<div class="collapse list-group-submenu" id="SubMenu2">
<a class="list-group-item2" href="#" data-parent="#SubMenu2">Fridge</a>
<a class="list-group-item2" href="#" data-parent="#SubMenu2">Freezer</a>
</div>
<a class="list-group-item1" href="javascript:;">Backgrounds</a>
</div>
<a class="list-group-item list-group-item-success" href="#demo4" data-toggle="collapse" data-parent="#MainMenu">Item 4</a>
<div class="collapse" id="demo4">
<a class="list-group-item1" href="">Subitem 1</a>
<a class="list-group-item1" href="">Subitem 2</a>
<a class="list-group-item1" href="">Subitem 3</a>
</div>
</div>
</div>
<ul class="nav navbar-nav navbar-right">
<li>
<asp:loginview runat="server" viewstatemode="Disabled">
<anonymoustemplate>
<ul class="nav navbar-nav navbar-right">
<li>Log in</li>
</ul>
</anonymoustemplate>
<loggedintemplate>
<ul class="nav navbar-nav navbar-right">
<li>
<asp:loginstatus runat="server" onloggingout="Unnamed_LoggingOut" logoutpageurl="~/" logouttext="Log off" logoutaction="Redirect">
</asp:loginstatus></li>
</ul>
</loggedintemplate>
</asp:loginview>
</li>
</ul>
</div>
</nav>
</div>
.navbar {
position: relative;
min-height: 50px;
border: 1px solid transparent;
overflow-x:hidden;
overflow-y:hidden;
max-height:100%;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
any advice on this would be amazing.
If you open up developer tools (F12 in Chrome/IE) and take a look at the computed tab for that element while it is expanded, you will see it has a max-height set, which is what is causing the scroll bar. To remove this, and have the max-height as the full screen, add max-height of 100vh to your CSS:
<div class="navbar-collapse collapse fullscreen-navbar-collapse">
.fullscreen-navbar-collapse {
max-height: 100vh;
}
If you only want it to this on smaller devices, wrap the CSS in a media query:
#media (max-width: 767px) {
.fullscreen-navbar-collapse {
max-height: 100vh;
}
}
I have a search textbox in navbar-header, on collapse, the width of the textbox is fine. But in full screen, the textbox width is reduced. How can I increase the width in full screen mode?
I know there are a lot of questions, like this on SO and the web.
However, I have tried all the suggestions, none has helped me.
here is my code, can someone tell what I'm doing wrong?
Thanks.
.navbar .navbar-form {
padding: 0 15px;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-inverse {
background: #465f62;
border: none;
}
.navbar-inverse .navbar-brand {
color: white;
font-size: 40px;
}
.navbar-inverse .navbar-nav > li > a {
color: white;
font-size: 18px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-collapse-area">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Colony</a>
<div class="col-sm-6 col-md-6 col-lg-8">
<form class="navbar-form" role="search">
<div class="form-group" style="display:inline;">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</div>
</form>
</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-area">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Hello Doe <span class="caret"></span>
<ul class="dropdown-menu pull-right">
<li class="dropdown">Log Out
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
JSBIN
Because bootstrap(BT) just use the default input width to achieve the navbar input. So if you want to redefine the width of input, maybe jquery is a better choice.
$(window).resize(function (){
var width = $(window).width();
$('input').width(width - 380);
})
the number 380 is from of the colony and Hello Doe width. After all, there is enough space to arrangement all elements.
I'm builing a website. This is the portfolio page: www.alweso.2ap.pl/portfolio.html
On all the other pages the navbar collapses on mobile phones, but not on this one. The code for the navbar is exactly the same as on the other pages:
<div class="container">
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- 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="#"><img src="images/logo-kolor.png" alt="cafeteria" class="logo-kolor"/></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>Strona główna</li>
<li>O mnie</li>
<li class="active">Portfolio</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
</div>
</div>
Also, the buttons on the portfolio page used for filtering the portfolio appear super small on mobile devices. Here's the code:
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="btn-group">
<button type="button" class="btn btn-large filter" data-filter=".wszystko">Wszystko</button>
<button type="button" class="btn btn-large filter" data-filter=".niemowleta">Sesje niemowlęce</button>
<button type="button" class="btn btn-large filter" data-filter=".dzieci">Sesje dziecięce</button>
<button type="button" class="btn btn-large filter" data-filter=".sluby">Sesje ślubne</button>
</div>
</div>
</div>
</div>
CSS:
.btn, .btn-default, .btn:focus, .btn:hover, .btn:active {
margin-left: 0;
margin-right: 20px;
margin-bottom: 30px;
box-shadow: none;
-webkit-box-shadow: none;
border-radius: 0;
border: rgba(255,255,255,0) !important;
}
.btn, .btn-default {
background-color: rgba(0,0,0,0.1);
color: rgba(0,0,0,0.7);
}
If it comes to the navbar, I copy-pasted the code from other pages just to be sure it's exactly the same, but it doesn't help at all and I'm out of ideas. Help extremely appreciated.
On line 6 of html try and change
<meta name="viewport" content="width=device-width, initial-scale=1">
I validated the page in W3C click here to see