My navigation bar currently looks like this:
My code is below:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
Text Planner
</a>
</div>
<% if user_signed_in? %>
<p class="navbar-text navbar-left">Welcome, <strong><%= current_user.first_name.to_s+" "+current_user.last_name.to_s %></strong></p>
<div class="nav navbar-nav navbar-right">
<%= link_to "Home", home_path, :class => 'btn btn-default navbar-button' %>
<div class="btn btn-default dropdown-toggle navbar-button" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Menu</div>
<ul class="dropdown-menu">
<li><%= link_to "Search For Events", root_path %></li>
<li><%= link_to "My Bookmarks", user_bookmarks_path(current_user.id)%></li>
<li><%= link_to "My Upcoming Reminders", user_reminders_path(current_user.id)%></li>
<li><%= link_to "My Profile", user_path(current_user.id)%></li>
<li role="separator" class="divider"></li>
<li><%= link_to "Logout", destroy_user_session_path, method: :delete %></li>
</ul>
</div>
<% else %>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", home_path, :class => 'navbar-text' %></li>
<li><%= link_to "Sign up", new_user_registration_path, :class => 'navbar-text' %></li>
<li><%= link_to "Login", new_user_session_path, :class => 'navbar-text' %></li>
</ul>
<% end %>
</div>
</nav>
How do I move the home and menu buttons to the left and center them vertically? Also, I would like to keep them clickable buttons while removing the outline of a button with the white background so they match the left side of my navigation bar. Thanks in advance.
It's very simple, actually, set your line-height and div height to the same (here's a quick example):
#navbar a{
width: 200px;
height: 40px;
display:inline-block;
color:white;
line-height:40px;
}
This is provided your buttons are formed using CSS, but I believe it works for other elements, as well.
Related
I have my navbar items in the order of "offerings," "about," and "contact us."
On the live website it is "about" then "contact us" then "offering"
Is there some sort of code or div grouping I can use to make sure they display in the order listed?
Pasting the code from my application.html.erb:
div class="navbar-order">
<ul class="nav navbar-nav navbar-right">
<div class="dropdown">
<button class="dropbtn"><li><%= link_to "Offerings", offerings_path %></li></button>
<div class="dropdown-content">
<li><%= link_to "Public Speaking", pages_public_speaking_path %></li>
<li><%= link_to "Nonverbal Communication", nonverbal_path %></li>
<li><%= link_to "Group Dynamics", group_dynamics_path %></li>
<li><%= link_to "Intercultural Communication", intercultural_communication_path %></li>
<li><%= link_to "Editing", editing_path %></li>
<li><%= link_to "Interviewing", interviewing_path %></li>
<li><%= link_to "Business Etiquette", business_etiquette_path %></li>
<li><%= link_to "Business Writing", business_writing_path %></li>
</div>
</div>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact Form", new_contact_path %></li>
</ul>
</div>
ul {
display:flex;
list-style-type: none;
}
ul li {
margin-right:20px;
}
<nav>
<ul>
<li>The</li>
<li> Correct</li>
<li>Order</li>
</ul>
</nav>
Try to re-structure Your HTML nav markup.
The point is that You should put <li>'s in the <ul> and not the divs. If You create the markup properly and put some
display:flex or display:inline-block on the <ul>, there is no way that it's displayed in the broken order
<div class="dropdown pull-right">
<a id="dropdown" data-toggle="dropdown" aria-haspopup="false" aria-expanded="true">
<%= theme_icon_tag "settings" %>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdown" style="padding: 0.25em">
<li><%= link_to "Edit", edit_book_review_path(review.book, review), class: "btn btn-outline-primary dropdown-item" %></li>
<li><%= link_to "Delete", book_review_path(review.book, review), method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-outline-danger dropdown-item" %></li>
</ul>
</div>
<% end %>
<% end %>
</div>
This is my dropdown and it's working fine on desktop.
Ive got my phone laying around and wanted to test it's functionality and I realized that I am not able to click the icon to open the dropdown-menu.
Why is that?
This link will help you stackoverflow.com/a/17841690/6392696
Find this file bootstrap.min.js , In substring
"ontouchstart"
Replace it with
"disable-ontouchstart"
Hopefully this will help!
I'm trying to create a navbar with two links generated in Ruby on Rails. For now, pretty much trying to make the brand on the left and either log in/sign up or log out/post ad on the right. However, my right nav bar is falling below on a new line. Like the width of the navbar isn't large enough to hold all the items.
Here is a screenshot of what I am describing....
The right navbar is falling below the brand.
index.html.erb
<nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">SHIP LIST</a>
</div>
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in?%>
<li><%= link_to 'post ad', new_listing_path %></li>
<li><a href="#"><%= link_to 'log out', destroy_user_session_path, :method => :delete %></li>
<% else %>
<li><a href="#"><%= link_to 'sign up', new_user_registration_path %></li>
<li><a href="#"><%= link_to 'log in', new_user_session_path %></li>
<% end %>
</ul>
</div>
My css is as follows, I did have to make changes with it so the alerts for Devise show below the navbar, so that may be causing it. I don't think it is but.
body {
font-size: 62.5%;
font-family: Helvetica, sans-serif;
}
.alert-box {
color:#555;
border-radius:10px;
font-family:Tahoma,Geneva,Arial,sans-serif;font-size:11px;
padding:10px 10px 10px 36px;
margin:10px;
span {
font-weight:bold;
text-transform:uppercase;
}
}
.danger {
background:#ffecec url('images/error.png') no-repeat 10px 50%;
border:1px solid #f5aca6;
}
.success {
background:#e9ffd9 url('images/success.png') no-repeat 10px 50%;
border:1px solid #a6ca8a;
}
.warning {
background:#fff8c4 url('images/warning.png') no-repeat 10px 50%;
border:1px solid #f2c779;
}
.notice {
background:#e3f7fc url('images/notice.png') no-repeat 10px 50%;
border:1px solid #8ed9f6;
}
With the following code pertaining to the right nav bar...
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in?%>
<li><%= link_to 'post ad', new_listing_path %></li>
<li><a href="#"><%= link_to 'log out', destroy_user_session_path, :method => :delete %></li>
<% else %>
<li><a href="#"><%= link_to 'sign up', new_user_registration_path %></li>
<li><a href="#"><%= link_to 'log in', new_user_session_path %></li>
<% end %>
</ul>
Remove the link tags like so...
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in?%>
<li><%= link_to 'post ad', new_listing_path %></a></li>
<li><%= link_to 'log out', destroy_user_session_path, :method => :delete %></li>
<% else %>
<li><%= link_to 'sign up', new_user_registration_path %></li>
<li><%= link_to 'log in', new_user_session_path %></li>
<% end %>
</ul>
Rails will automatically generate them for you, so you don't need to add them in like that manually. It was overflowing as it was trying to add in four links instead of two. Nothing to do with the Devise gem, that is being generated in the body of the HTML page.
I'm trying to customise the navigation bar on a website. The part that I'm having trouble with is the three line thing that should reveal the rest of the menu in a drop down way when the screen is small.
When I click on the 3 line button, nothing happens and I can't access the rest of the menu bar but it changes colour when I click it so I know it knows that I have clicked on it.
Here is my application.html file:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to 'Home', root_path, class: 'navbar-brand' %>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<%= render 'layouts/navigation_links' %>
</ul>
</div>
</div>
</nav>
and here is the layout/navigation_links that list the links that I want to show
<%# add navigation links to this file %>
<% if user_signed_in? %>
<li><%= link_to 'Edit account', edit_user_registration_path %></li>
<li><%= link_to 'Sign out', destroy_user_session_path, :method=>'delete' %></li>
<% else %>
<li><%= link_to 'Sign in', new_user_session_path %></li>
<li><%= link_to 'Sign up', new_user_registration_path %></li>
<% end %>
<% if user_signed_in? %>
<li><%= link_to 'Users', users_path %></li>
<% end %>
and here is my application.css file (under assets/stylesheets)
body{
margin-right: 10px;
margin-left: 10px;
background-color: #eeeeee;
}
.navbar-inverse{
background-color: #000000;
}
.navbar-inverse{
border-color: #33aa22;
}
When the webpage is full size the rest of the menu bar appears and the navigation_links appear and work.
I have no clue why it isnt working when the page is small so any help would be great!
I am using bootstrap for creating twitter like app. The contents on the nav bar, under "nav pull-right" disappears when the window size resized to small. How do i do that? Here is my erb file..
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<%= link_to "cntwitter", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right" id="right_nav">
<li><%= link_to "Home", root_path %></li>
<% if signed_in? %>
<li><%= link_to "Users", users_path %></li>
<li id="fat-menu" class="dropdown">
Account <b class="caret"></b>
<ul class="dropdown-menu">
<li><%= link_to "Profile", current_user %></li>
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
<li class="divider"></li>
<li>
<%= link_to "Sign out", signout_path, method: "delete" %>
</li>
</ul>
</li>
<% else %>
<li><%= link_to "Sign in", signin_path %></li>
<% end %>
</ul>
</nav>
</div>
</div>
</header>
The twitter bootstrap scaffolding, or grid, is static by default. It sounds like you want the contents of your web page to scale with the browser window. In that case, I would recommend using the "fluid" scaffolding :: http://twitter.github.com/bootstrap/scaffolding.html#fluidGridSystem