I have designed the site and when I resize the browser window or use the tools Firefox provides for responsiveness, I don't see navigation bar breaking and I don't own a tablet but a few friends do and they say the navigation bar is not showing up correctly.
I don't understand what I am doing wrong!
This is the site
Edited:
The navigation bar li item should be floating right. Apple users say that when they open the site, it opens fine. But once they scroll down and back up, the li items do not line up on the right but come in between.
I think #khilley made a particularly valid point about using standard Bootstrap markup and built-in javascript components. Here's some reasons why:
Your current approach uses duplicative markup (for your menu). It's not DRY or accessible and it requires more effort to maintain.
If you don't need to write your own javascript, you save time in development and testing, and a couple of download bytes for your users.
Twitter Bootstrap is used on millions of websites, so it gets field tested by millions of people on millions of different device/OS/resolution combinations everyday around the world. When you use the standard markup and javascript component plugins, you get the benefit of knowing it's just going to work.
More to the point, you can easily reproduce all of the behaviors of your navigation, with just some styling, including using the built-in affix markup to handle the change in your navbar. Pretty sweet!
DEMO
There were only a few changes made to your markup and css to accomplish this. You can eliminate all of your custom javascript now except for the one click handler that you use for scrolling to your different sections.
Replace all of your navigation styles and markup with the following:
HTML:
<nav class="navbar nav-custom navbar-fixed-top" data-spy="affix" data-offset-top="80" role="navigation">
<div class="container-fluid">
<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="glyphicon glyphicon-th-list"></span>
</button>
<span class="rc">RC</span>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">
Home
</li>
<li>
Design
</li>
<li>
Develop
</li>
<li>
Contact
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
CSS:
.nav-custom {
width: 100%;
height: 80px;
z-index: 999;
padding: 25px;
background-color: #f87f73;
border-bottom: 1px solid rgba(0, 0, 0, 0.18);
font-size: 150%;
color: #fff;
-webkit-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
.nav-custom.affix {
width: 100%;
background-color: rgba(255, 255, 255, 1);
color: #f87f73;
height: 60px;
padding: 14px;
-webkit-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
.nav-custom .rc {
background-color: #fff;
color: #f87f73;
padding: 5px;
border-radius: 50% 0% 50% 0%;
float: none;
}
.nav-custom.affix .rc {
background-color: #f87f73;
color: #fff;
}
.nav-custom.affix .navbar-collapse {
top: 60px;
}
.nav>li>a:hover, .nav>li>a:focus {
background-color: transparent;
}
button{
outline: none;
}
.navbar-toggle {
padding: 0;
margin: 0;
}
#media (min-width: 768px) {
.nav-custom a::before,
.nav-custom a::after {
display: inline-block;
opacity: 0;
-webkit-transition: -webkit-transform 0.3s, opacity 0.2s;
-moz-transition: -moz-transform 0.3s, opacity 0.2s;
transition: transform 0.3s, opacity 0.2s;
}
.nav-custom a::before {
margin-right: 10px;
content: '[';
-webkit-transform: translateX(20px);
-moz-transform: translateX(20px);
transform: translateX(20px);
}
.nav-custom a::after {
margin-left: 10px;
content: ']';
-webkit-transform: translateX(-20px);
-moz-transform: translateX(-20px);
transform: translateX(-20px);
}
.nav-custom a:hover::before,
.nav-custom a:hover::after,
.nav-custom a:focus::before,
.nav-custom a:focus::after {
opacity: 1;
-webkit-transform: translateX(0px);
-moz-transform: translateX(0px);
transform: translateX(0px);
}
.nav-custom a:link, .nav-custom a:visited, .nav-custom a:hover, .nav-custom a:active {
text-decoration: none;
color: #fff;
outline: none;
}
.nav-custom.affix a:link, .nav-custom.affix a:visited, .nav-custom.affix a:hover, .nav-custom.affix a:active {
text-decoration: none;
color: #f87f73;
outline: none;
}
}
#media (max-width: 767px) {
.navbar-collapse {
width: 250px;
position: fixed;
right: -250px;
top: 80px;
overflow-x: hidden;
background-color: rgba(255, 255, 255, 0.8);
border-top: none;
-webkit-box-shadow: none;
box-shadow: none;
-webkit-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
.navbar-collapse.in {
right: 0px;
width: 250px;
-webkit-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
.navbar-collapse.collapsing {
height: auto !important;
}
.navbar-nav {
margin: 0 -15px;
}
.navbar-nav>li>a {
padding: 0;
line-height: 3em;
text-align: center;
}
.navbar-collapse ul {
border-left: 1px solid rgba(0, 0, 0, .18);
}
.navbar-collapse ul li {
border-bottom: 1px solid rgba(0, 0, 0, .18);
}
.navbar-collapse ul li:hover {
background-color: #f87f73;
color: #fff;
-webkit-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
.navbar-collapse ul a:link,
.navbar-collapse ul a:visited {
color: #f87f73;
}
.navbar ul a:hover {
text-decoration: none;
color: #fff;
}
}
How it works:
The navbar-fixed-top class is used instead of custom styles.
Instead of writing your own javascript to handle changing your navbar when you scroll, you can use Bootstrap Affix. This built-in javascript plugin can use the data-offset-top attribute to set the point at which the affix class is automatically appended to the element where the data-spy attribute is set. Using the data attributes, you don't need a single line of javascript, just add the styles for how you want your element to look once the affix class is applied. Now all of your styles are in your CSS and none need to be in your javascript.
Use the built in navbar-toggle, which uses the built in Bootstrap Collapse plugin to transition to and from the mobile navigation. This eliminates the need to write/test/maintain your own javascript and eliminates the duplicative markup you have for the menu. The collapse plugin applies the in class to the element with the collapse class when the menu is expanded, so you can just use this for styling your menu.
Use media queries to change the layout of the menu based on the viewport size. The "mobile" menu is only displayed at viewports less that 767px, so you can easily target how you want the mobile menu to be styled.
Overall, the CSS is virtually identical to your CSS, I just changed the selectors to reflect the changes in the markup. Aside from a few minor tweaks, it was pretty much cut and pasted from your site.
When the page opens your nav is insisde the HTML block
<div class="row nav-custom nav-custom"> ... </div>
And on scrolling the nav is inside the block
<div class="row nav-custom nav-custom-2"> ... </div>
In your stylesheet http://rohanchhabra.in/css/custom.css you have padding:25px; and padding:14px; for .nav-custom and .nav-custom-2 which breaks the Bootstrap grid because there isn't enough width to place your col-sm-3 and col-sm-9 columns without breaking the row into two lines.
You could either remove or edit the padding for these 2 classes so that you aren't adding any extra horizontal space e.g.
.nav-custom{
padding-top:15px;
padding-bottom:15px;
}
or place the nav-custom class inside your col class, e.g.
<div class="row">
<div class="col-xs-3 col-sm-3">
<div class="nav-custom"> ... </div>
</div>
...
</div>
The key thing here is that you never want to had horizontal padding to any of the bootstrap row or column elements or you risk breaking the Bootstrap grid
Good luck!
It's possible you've hit upon a Safari web browser bug, since this issue seems to only get recreated on Macs. I can recreate the issue on OSX 10.8, running Safari 6.1. A browser refresh, or clicking on any of the nav values clears the issue and resets the nav display to the desired position. You could look into filing a bug for this potential Safari display issue.
That being said, my suggestion to resolve this issue is to refactor your HTML to better leverage the core Bootstrap navigation components. Currently you've got the navigation split in different div containers, and have it separate for wide screen and mobile. A more standard Bootstrap navigation element would look like:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Static navbar -->
<nav class="navbar navbar-custom navbar-inverse navbar-fixed-top" role="navigation">
<div class="container" id="nav-container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href=""><img src="" class="Logo" alt="Rohan Chhabra Designer and Developer"></a>
<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>
</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>Home</li>
<li>Design</li>
<li>Develop</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- End Static navbar -->
You'll of course need to add some amount of custom.css styling to this code example, and it assumes your logo is an image (so rework that accordingly), BUT I think that by using this more 'standard' navigation implementation of Bootstrap navigation you'll be in better shape in the long run. I've tested out Boostrap websites using this style navigation and they do not have the Safari display issue seen in your example.
I have validate your site with w3c validator.
There is some critical issues found need to be correct.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
I recommend this line should come with IE conditional comments like below line.
<!-- [if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
And Anchor tag is not allowed as child of element ul
Please current those issues and check. It will definitely fix your site issues.
You may try using media queries for different window sizes..
https://developers.google.com/web/fundamentals/layouts/rwd-fundamentals/use-media-queries?hl=en.
This might be helpful for you.
Related
I am currently trying to make a h1 link that transforms when hovering over it. This works perfectly, when placing the /a outside of h1 However, doing this resolves in making the whole element react and clickable when hovering over it - it just looks bad. Placing /a inside /h1 makes only the text clickable as desired - yet it doesn't react to hover, but to all other changes it does.
Please note that I am a beginner and I do not know what exact context is required for you to help me.
This lets hover work, but makes the whole element clickable.
#headlines a:hover {
transform: scale(1.5);
transition: 0.1s;
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html"
id="headlines"
style="text-decoration: none; color: black">
<h1> Headlines
</h1></a>
<hr>
</div>
Apply transform to the h1 on hover...but make the h1 as display:inline-block so it's no bigger than it needs to be.
The link will always be clickable but it should solve the sizing issue.
a#headlines h1 {
display: inline-block;
}
a#headlines h1 {
transition: transform .5s ease;
}
a#headlines h1:hover {
transform: scale(1.5);
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html" id="headlines" style="text-decoration: none; color: black">
<h1> Headlines
</h1>
</a>
<hr>
</div>
you can try it
a#headlines:hover {
transition: transform .5s ease;
transform: scale(1.5);
}
Just add this:
a {
font-weight: bold;
font-size: 45px;
transition: all 500ms;
}
a:hover {
font-size:60px;
font-size-adjust: 20px;
}
This is the Fiddle
I'm searching a way to make an css effect but with exception of not applying the effect to the letters and the buttons (Only to the image), so I need create a rule in css. I can't change the order of the things.
With my code, I get something like this.
This is my code, like you can see I applied some effect in css and this is getting applied to all. I only need it for the image.
.myimage01 {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" data-style="background-image: url(http:www.myurl.com/image.jpg);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
When I apply the effect apply the effect to the letters (h5, h3, p and the button with btn class)
I don't want the effect for them, only for the background-image.
How can I do?
for transition backgrounds use the property background-size, and use background-position to adjust as fits you better
body {
margin: 0
}
.myimage01 {
background-size: 100%;
background-position:center center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
background-image: url(http://lorempixel.com/1600/900);
padding: 40px 30px;
color: #ffffff;
text-align: center;
}
.myimage01:hover {
background-size: 130%;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
Use background-size for transition:
div {
background-image: url(http://lorempixel.com/400/200/sports/1/);
background-size: 100%;
background-repeat:no-repeat;
background-position:50% 50%;
width:400px;
height:200px;
transition: background-size 200ms linear;
text-align:center;
line-height:200px;
}
div:hover {
background-size: 120%;
}
<div>
Some text
</div>
try to transform the background-size property instead of scaling the whole container.
You can apply transform on background-size, background-position to get the effect on the background image.
.myimage01 {
background-size:100%;
background-position:0px 0px;
-webkit-transform: all;
transform: all;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
background-size:140%;
background-position:-50px -50px;
-webkit-transform: all;
transform: all;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" style="background-image: url(http://dummyimage.com/600x200/000/fff);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
I'm working on a project of mine and I've got a relatively interesting idea that would look pretty nice, only issue is, I can't really figure out how to pull it off.
here's the deal. I've got my navigation bar set up and it looks something like this
Now for illustration purposes i've margined the small arrow under it. As in now, it's only a lone <img> placed under the navbar and margin applied to it to make it look like it's under it.
Basically what I'm trying to accomplish is, whenever you hover over a certain part of the navigation bar, the arrow will move under it. For sake of simplicity and readability of this post, let's not discuss any animations and smoothness, literally all I want is for the arrow to disappear from the original position and re-appear under the desired (hovered-over) location.
Any suggestions what would be the best (and easiest) way to pull this off?
Ideally I'd prefer usage of HTML/CSS only.
Probably only solution I came to so far is creating a separate arrow for each item inside the navigation bar.
Set it to
.nav img {
display: inline-block;
visbility: hidden;
}
And then create
.nav img:hover {
visiblity: visible;
}
Now there's multiple issues with this.
1) This would mean, people would need to hover on the arrows under it, intead of the actual navbar items for them to appear.
2) I would need to manually margin each and every arrow for them to fit under every single menu item.
3) While this would work on my screen, if you switch to any different resolution, the margin would be off for them.
I'm interested to hear, if you guys have any suggestions.
EDIT: I actually figured out a solution, that I can simply create a dropdown menu (another ul) and just put image there. Though if you still have any more intuitive and better working solutions, I'll be happy to view them.
If I understand your question correctly you can achieve this by doing the following without any images. I have added the class of active and given this a unique color to show what page you are currently viewing and then the hover effect will follow in a different color. The selector will be a psuedo element with pure css triangle and will show on hover.
Here is a fiddle to show you this in action Fiddle
And the markup:
<nav>
<ul>
<li><a class="active" href="#">Link</a></li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</nav>
and the css like this:
nav{
text-align: center;
background: #000;
}
nav ul{
list-style-type: none;
padding: 0;
margin:0;
}
nav li{
display:inline-block;
position: relative
}
nav li a{
color: #fff;
padding: 10px;
display: inline-block;
text-decoration: none;
}
nav li a:before{
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid rgba(200,200,200,1);
position: absolute;
bottom:-20px;
left:0;right: 0;
margin: 0 auto;
content:'';
opacity: 0;
-ms-transition: opacity 300ms ease-in-out;
-moz-transition: opacity 300ms ease-in-out;
-webkit-transition: opacity 300ms ease-in-out;
-o-transition: opacity 300ms ease-in-out;
transition: opacity 300ms ease-in-out;
}
nav li a.active:before{
opacity: 1;
border-top: 20px solid red;
}
nav li a:hover:before{
opacity: 1;
}
I'm trying to recreate a similar menu effect found on the World War Z movie site, but I can't seem get the CSS transition working correctly. I've gotten the hover element to display the hidden block, but the CSS transition wont work. I'm trying to get a cool effect that would slide from the top or bottom, I don't have a specific preference. Also if I try to go over any of the links, the submenu disappears before I can click on it. Here's the Fiddle.
HTML:
<ul id="menutitle">Menu Title</ul>
<ul id="submenu">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</nav>
CSS:
#topmenu {
background: #000;
width: 150px;
height: 50px;
color: #fff;
}
#submenu {
display: block;
position: absolute;
width: 110px;
display: none;
background: #333;
list-style: none;
line-height: 2em;
}
#menutitle:hover + #submenu {
display: block;
-webkit-transition: height 1s ease;
-moz-transition: ease-in 2s none;
-ms-transition: ease-in 2s none;
-o-transition: ease-in 2s none;
transition: ease-in 2s none;
}
#menutitle { color: #ff0000; }
a { color: #FF0; }
A few things:
Your :hover selector should be on the #topmenu element, not the title. That's why the nav area is disappearing so suddenly - it only takes hovering on the menu text.
You might have a little misconception of the animate property definition. You need to pick a specific property to animate; usually something like 'height'. In this case, my solution was to set "max-height". There may be some way of setting height to something like 'auto', but if so it's lost on me.
Additionally, the "transition" property is set on the object at all times - not just 'when hovering'. It's a sort of constant state to indicate "WHEN this property changes, do a smooth transition". That way, you can have a series of different states giving different heights.
http://jsfiddle.net/8YHbq/4/
#topmenu {background: #000; width: 150px; height: 50px; color: #fff; }
#submenu {display: block;
position: absolute;
width: 110px;
background: #333;
list-style: none;
line-height: 2em;
overflow: hidden;
max-height:0;
transition: max-height 0.7s ease-in;
}
#topmenu:hover #submenu {
max-height: 200px;}
#menutitle {color: #ff0000;}
a {color: #FF0}
Currently, the one issue with my version that I'm just now realizing is that since max height animates to 200px, the nav menu will be fully expanded before it reaches 200 - making the animation less smooth. Maybe you could adjust that a bit based on your needs.
I posted a question last night about using media queries Fixed header and a responsive website issue
So I thought I finally cracked it but what seems to happen is when the screen is resized down the text jumps to the left and disappears. I thought all i had to do was make the #nav-wrapper the same size and the screen it will be on.
Here is the code
HTML
<body>
<div class="container">
<nav id="main-nav">
<div class="inner-nav" id="nav-wrapper">
<div class="ten columns">
<ul>
<li>Test</li>
<li>Test</li>
<li>Test</li>
</div>
</div>
</nav>
</body>
</html>
CSS - In Scss format as the CSS is compressed
//Navigation
#main-nav {
-webkit-box-shadow: 0 2px 15px rgba(0, 0, 0, 0.25);
-moz-box-shadow: 0 2px 15px rgba(0,0,0,0.25);
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.25);
-webkit-transition: box-shadow 0.2s linear;
-moz-transition: box-shadow 0.2s linear;
-ms-transition: box-shadow 0.2s linear;
-o-transition: box-shadow 0.2s linear;
transition: box-shadow 0.2s linear;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
display: block;
position: fixed;
top: 0;
left: 0;
float: left;
width: 100%;
z-index: 12;
height: 60px;
background-color: white;
#wrapper {
position: relative;
}
.inner-nav {
margin-left: auto;
margin-right: auto;
width: 800px;
}
ul {
float: right;
margin: 0;
width: 600px;
li {
vertical-align: middle;
display: inline;
margin: 0 2px;
color: black;
list-style-type: none;
a {
text-decoration: none;
}
}
}
}
And the media query I am calling
/* All Mobile Sizes (devices and browser) */
#media only screen and (max-width: 767px) {
#nav-wrapper{
width:767px;
}
}
Can anyone tell me what I have to do so when the screen is mobile lets say the nav just resizes to fit the screen. Also I know the position:fixedthat how i want it so when the user scrolls the nav bar stays at the top. Although if there is a way to make the nav cover the top of the whole site I then wouldnt have to useposition:fixed as the framework I am using (http://www.getskeleton.com/) doesn't seem to allow me to do this.
I am trying to have a design like https://simple.com/ although not with the jQuery stuff just the nav at the top then the header across the page and content under. I have tried looks at their source but they are using custom style sheets and they are also compressed.
EDIT
It may not be clear what I am after, I want a website with a fixed header which is also responsive so on mobile devices it will fit the screen. The simple site is something im working off if anyone knows how they did there site im all ears.
The problem I see with your media query is that when the screen has a width bellow 767px you're telling the css processor to render the nav-wrapper element with a width of 767px. So, if a user accesses the page via a 480px width device, it would overflow the screen.
I'm not sure I understand what you're trying to accomplish, but my best suggest is to set the width to 100% in your media query (or delete it completely, and inherit the width:100% from the previous CSS declaration for that element).