What I'm Trying To Do (including JSBin)
My nav bar works fine on a desktop: when you click on an item, it scans to that section of the page, beginning with the header. However, when I resize to mobile, the spacing is off. When you click on "Section 2" on the navbar, you should see "Section 2" pop up directly below the navbar.
See example on JSBin.(Use Developer tools to show on mobile to see the problem when clicking around the nav bar).
What I've Tried/What I Think The Problem Is
I'm pretty sure it has to do with this:
.anchor:before {
display: block;
content: " ";
margin-top: -75px;
height: 75px;
visibility: hidden;
}
Which I got from this Github page, but I can't figure out how to automatically change the 75px number depending on the screen size. I read this question/answer but still can't figure out how to change the CSS in my case.
It looks like that page is for Bootstrap. What you're looking for is built directly into CSS!
Check out this page.
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
Essentially what's happening to you is that, once your page is scaled down to a mobile device. It causes your buttons (the text elements) to stack, causing your nav to be vertically larger than it should be!
To answer your code question try something like this:
.anchor:before {
display: block;
content: " ";
margin-top: -75px;
height: 75px;
visibility: hidden;
}
#media only screen and (max-width: 480px) {
.anchor:before {
height: 65px;
}
}
What happens is that once your screen width goes unter 480px (this value can be tweaked to whatever you need it to be) it will run the height: 65px; and override the height style from the one above it.
Another way you can prevent your nav bar from resizing when you don't want it to is by setting overflow: hidden; and then specifically defining what you want the height to be. (Personally I like to use height: 47px;. It feels like a perfect size to me)
That should answer your question. However, what you should really do is look into compiling all of your nav buttons into a dropdown menu once your screen shrinks to be small enough.
If you're feeling up to it, check out this page:
https://www.w3schools.com/howto/howto_js_topnav_responsive.asp
Related
I've got a problem with the taborder (keyboard focus) in a header. The header consists of a navigation, logo, some buttons and a link. In desktop the logo is left aligned and the menu is expanded but when the screen gets small the logo changes position to the center of the header and the menu is toggable with a hamburger icon. My issue is that if I put the navigation before the logo in the html, it works on small screens but in desktop the navigation gets focused first, which causes the user to navigate trough the whole navigation before going to the rest of the header content. So my question is, how can I solve it so that the taborder always start at the same position dispite which content it has? I don't want to set taborder=1, 2 etc.
Desktop:
[Logo] [Buttons] [Link]
[Expanded navigation] (below header)
Mobile: [Hamburger icon] [Logo] [Link]
I want the taborder to be Logo -> Buttons -> Link -> Expanded navigation, for desktop and for mobile: Hamburger -> Logo -> Link
I hope the question is understandable.
EDIT
Added an example of my problem: fiddle
And this is the css in the example:
header {
position: relative;
}
.button {
display: block;
position: absolute;
top: 0;
left: 0;
}
.content {
margin: 0 auto;
width: 100px;
text-align: center;
}
#media screen and (min-width: 480px) {
.button {
display: none;
}
.content {
margin: 0;
text-align: left;
}
}
A common idiom is to provide a "skip links" tab stop at the very top of the document, or at least before the links you want to skip. This special tab stop can be hidden from view until focused with the tab key, so nobody needs to know it's there unless they're using a keyboard.
https://webaim.org/techniques/skipnav/
Bear in mind that screen reader users will usually have alternative ways to navigate around the document without using explicit tab stops. Browsing by headings is very common, for example.
I have a nav bar, in which some links are provided. For ease's sake, I've only included one link in the code below. This navigation bar's height is automatically determined by the font-size used by the links. Now here's my problem: I want to add an img to the bar, that fills up the bar, however big it may get because of the links.
This is for a mobile website. Now I may be noob in this area, but I've noticed that smartphone browsers handle a website way differently than desktop browsers scaled down. Following that logic, I don't want to hardcode the size of the elements because it might scale weirdly on other devices. I want everything to be determined by one value, if possible.
I've read some things about display: flex; but truth is, I can't figure out how it works. I've tried setting the height of the img to 100% but since the height of the nav is by default auto and thus set by the font-size of the links, that doesn't work.
HTML:
<nav>
<img src="/include/img/logo/flame.svg" alt="info"/>
Link
</nav>
CSS: (only positioning/scaling properties included, so no colors etc.)
nav {
display: flex;
padding-left: .5%;
padding-right: .5%;
}
nav a {
padding: 10px;
float: left;
font-size: 4em;
}
I want it to look like this (image height manually set in pixels)
But of course, it looks like this (sorry, can't post pictures yet)
(the image has some white space beneath it, which is 'to be fixed')
Any ideas? I can't be the only one who has ever had this issue.
The situation i'm facing :
i have an asp.net with a header, sidebar and another right sidebar. the thing is when i execute my website in browser and mimimize browser window. the sidebar on the left jumps on the content page and controls get all mixed. see picture for an idea.
Another problem is when i executed that website in a wider screen resolution the controls ( panels ) had a bigger margin and evertyhing look wider.
Any ideas how to fix this ?
Thank you in advance
EDIT:
Sidepanel ( right ) CSS code:
#droite
{
position: fixed;
top: 22.5em;
right: 5%;
width: 13%;
background-color: White;
}
What I did on my website (firedrake969.github.io) was add some simple jQuery code to hide the sidebar whenever the window became too small. If you don't mind using jQuery, I'd say that's the way to go. However, if you don't want to use jQuery, I don't think position:fixed can have the bar hide just with CSS/HTML if the browser window gets too small.
You probably need something similar to this. the max-width can be set to any screen width you choose.
#media screen and (max-width:768px) {
#droite
{
position: fixed;
top: 22.5em;
left:5%;
width: 100%;
background-color: White;
}
}
Hoping that the community will be able to help me out here as I really am stuck. I've having 3 I issues with my website:
Website Link
For some odd reason - I can't get my columns to line up straight. The entire page seems to be more to the right than in the centre on both desktop and mobile
What I'm trying to do with the top image is have it take up the entire page upon loading, and then as you scroll, the image disappears. For some reason, on mobile, the image doesn't cut off and allows for the user to scroll to the right.
On mobile, I can't get the top image to show properly. It stretches vertically, and users have to scroll all the way past the photo to get to my content... I want the main image to resize like it does on a desktop browser and only take up the screen real estate when the page loads
Any advice here would be helpful...
In your projects sections - if that is where your issue is has padding on a UL tag - which is causing it to look misaligned.
You could do this to fix that section:
ul.skillssection {
padding-left: 0;
}
It'll be more helpful for the community if you made points or set up a jsfiddle.
Update - answer for number 2.
I can't seem to replicate it but I've noticed you've got:
img.bg {
min-height: 100%;
width: 100%;
min-width: 780px;
overflow: hidden;
}
I would change it to:
img.bg {
min-height: 100%;
max-width: 100%;
overflow: hidden;
}
So the max-width is always 100% and it should follow the width of the parent.
I have a responsive site I am working on. It has a gap of white space on the right side of the screen at screen sizes roughly below 767px. This is the point it goes to the "mobile" layout. I had the same issue on the desktop size and fixed it by setting the footer to 99% width and it fixed the issue on the larger screen sizes. I tried playing with the footer width for the mobile size, but with no luck.
I have not idea what is causing this white space on the right side of the screen on smaller viewports. I tried the inspect tool in the console, but I couldn't find the problem.
I would post code, but seeing as I can't track the problem down, I wouldn't know what to post.
URL of page: http://sevenclanscasino.designangler.com/warroad/warroad-home
For anyone with a similar issue and struggling by hovering over elements in devtools, I came across this trick on another forum.
* { border: 1px solid red !important; }
This very very helpfully shows you all the boundaries in your project. In my case it was a grid overflowing its parent. Enjoy!
Try to change some elements into your css.
.row { margin-left: 0; margin-right: 0; }
header #top-nav-container #top-nav { width: 100%; }
header #top-nav-container #top-nav { margin-left: 0; }
another way (but please dont do that) :
body { overflow: hidden; }
When working on a responsive website, you should always set width values in % rather than px. So try setting with:100%
Hope this helps.