Having issues trying to make fixed navigation bar mobile responsive - html

i'm working on FCC Technical Documentation Page and i'm having an issue, i'm trying to make this project mobile responsive, but i'm running into an issue where I can't seem to figure out how to move my left fixed nav bar and transition it to a top nav bar that is center aligned at anything below 920px, if you can be of any help I would appreciate it. I will link the project below so anyone can look at the code.
EDIT Finished making the project mobile responsive, might not be the most efficient method but it worked as i'm learning, click the link to view the code to see what I did that worked.
https://codepen.io/ochovj/pen/eYvwmYr
#media screen and (max-width: 920px) {
.nav-ul {
position: relative;
top: 0;
margin: 0;
padding: 0;
text-align: center;
float: none;
}
}
/* End of Responsiveness */
/* Nav Bar Container */
#navbar {
position: fixed;
width: 290px;
height: 100%;
top: 0px;
left: 0px;
border: 2px solid black;
background-color: white;
padding: 50px 0;
}

The easiest way would be to make your navbar list display: flex at the desired breakpoint:
#media screen and (max-width: 920px) {
.nav-ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
}
display: flex alone should do roughly what you want, but flex-wrap: wrap allows multiple rows if your elements don't all fit on a single line and justify-content: center will center the <li> elements inside the <ul> parent.
The list elements will need more styling, like padding, as they'll just be squished in a row together -- but this will quickly fix your position issue.

Related

Dropdown Style Issue in the CSS

I have a main horizontal menu inside a div. I want the dropdown menu to appear left underneath the div button that say "View The Perceptors". Now it just expands the div of the container when the dropdown is visible.
How can I make the dropdown go stay within the div? View the website link:
https://perception.works/
CSS CODE:
.dropdown {
position: absolute;
z-index: 1;
display: flex;
flex-direction: column;
color: white;
padding: 2.4em;
gap: 65px;
/* width: 100%; */
background-color: #181024;
}
You should have mentioned that you are trying to achieve this on responsive mode because otherwise on pc mode it didn't looked so good and I couldn't find where's the dropdown or menu!
Change
.dropdown_menu{
height:auto;
}
and delete position absolute from your .dropdown because you are just making it to appear on top of everything and to not care about other elements.
Also still, your button is not working.
Main problem here is that if you want to have your .dropdown within the div container (.dropdown__menu) there will be some text that does not stay in the .dropdown.
.dropdown__menu {
position: relative;
}
.dropdown {
position: absolute;
z-index: 1;
display: flex;
flex-direction: column;
color: white;
padding: 2.4em;
gap: 65px;
width: 100%;
background-color: #181024;
}
An easy solution to this problem will require a little change to the layout by unsetting the property display: flex; from the .social-links class (basically just remove the class from the CSS file).
Result
The final layout is presented as follows:
More references
Additionally you could try setting the overflow of the text, here a couple links:
How do i make wrapper div correctly wrap divs inside of it?
https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow

How to fix responsive image display with inherited padding

I am modifying a joomla virtuemart template. I have added the banner image in a custom code block that I have placed in an existing module position. As such it has inherited some css properties around it that appear to be giving it padding. My banner should display the full width of the top menu bar (you can see it here: https://www.artisanbelle.com). I don't know how to remove the padding and fix the display. It has displayed the correct image, which is 1920px wide and when I had this same image displayed in the pre-existing slider, it fitted across the menu bar fine.
The code I have tried is below. Also this is the first time I am using srcset and sizes, so if I am doing anything wrong there, please let me know.
<div class='illustrationz'>
<img src='https://www.artisanbelle.com/images/stories/mainlg.jpg'
srcset='https://www.artisanbelle.com/images/stories/mainxsm.jpg 600w,
https://www.artisanbelle.com/images/stories/mainsm.jpg 960w,
https://www.artisanbelle.com/images/stories/mainmd.jpg 1280w,
https://www.artisanbelle.com/images/stories/mainlg.jpg 1920w'
sizes='(min-width: 600px) 960px, (min-width: 960px) 1280px, (min-width: 1280px) 1920px, 100vw'/>
</div>
</div>
.illustrationz img {
width: 100%;
display: block;
}
.sectionz {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}
.headerz {
height: auto;
justify-content: inherit;
align-items: inherit;
}
And this is the code that the template is wrapping this section in:
<div class="mod-slider-cont">
<div class="container">
<div class="inner-container">
<div class="custom"
And the template css that goes with it. I'm having trouble finding mod-slider-cont:
.vpf-topbar .inner-container {
border-bottom: 1px solid transparent;
padding: 5px 0;
margin-bottom: -1px;
}
#vpf-header .navbar .container .inner-container {
padding-bottom: 20px;
margin-bottom: -1px;
}
There's a bit of a formatting issue here, you could use this as a fix:
.illustrationz img {
width: 100vw; // Use viewport width here instead.
display: block;
}
Although I've seen it used like this, the sizes attribute is typically only used it rel=icon and you'd be better off using css media queries for this.

<div>s go to full screen width on desktop but not mobile why?

I'm at a complete loss on what's pushing out my viewport.
I have <div>s which should stretch 100% across the screen but stop short, and I have no idea why.
I've been hacking at this for hours, and fixed the sideways scroll, I had padding on the flex-keys style which was forcing it too wide. Removing this eliminated the scroll but simultaneously the full width <div>s started stopping a few px from the right of the screen.
I'd love somebodies intuitions. Or really how to go about hunting down the problem.
If you click through to the site I've put borders around every element using
*{ border: 1px solid red; }
So if someone can instantly see what's causing the trouble, that'd help. The container <div>s for the hero-image and slideshow appear to exceed the viewport, but they're set to 100% so I have no idea why, or how to fix it.
I'd love some kind eyes.
https://pottertour.co.uk/index2.html
Remove the padding from the following classes.
index2.html:524
#media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm)
.flex-container {
width: 100%;
/* padding-left: 5px; */
/* padding-right: 5px; */
display: flex;
flex-wrap: wrap;
align-items: center;
margin: auto;
}
styles-boxes-test.css:414
.flex-container {
width: 100%;
/* padding-left: 5px; */
/* padding-right: 5px; */
display: flex;
flex-wrap: wrap;
align-items: center;
margin: auto;
}

How can I modify the CSS of WordPress "Amadeus" Theme to be centered?

I am having real difficulties centering and aligning a theme in Wordpress called "Amadeus". The website is heidikaloustian.com. I want the width of .content-area which is 740px and center it, the menu should be left aligned and the menu right aligned within it according to the mockup. Help, what am I missing?
Mockup of centered design;
Here's a start for you:
/* Line 1117 in style.css */
.site-header {
text-align: left;
background-color: #fff;
width: 740px;
margin: auto;
}
/* Line 1199 in style.css */
.site-content {
text-align: center;
margin-top: 0px;
width: 740px;
}
Since your content is limited to 740px I set the entire page content and header to that width and it gives the look you show in your mock-up.
What you could do is the following:
#page {
width: 740px;
margin: 0 auto;
}
.site-header {
display: flex;
}
.main-navigation {
align-self: flex-end;
}
.main-navigation li {
padding: 14px;
}
You will need to remove the container class from the site header and from the main-navigation.
Also remember to add the flexbox prefixes, in case you're going to support other browsers.

Have a fixed nav-bar but still keep scrolling active

My issue here is that I have my nav-bar set to fixed, so it follows the window and sits at the top of the page wherever they are, but when the page width is decreased the rest of the navbar items get cut off and I can't scroll to see the rest of the items. I already have a min-width set so it stops at a certain point. So when the page width is decreased I want user to be able to be able to scroll around the page and be able to see the rest of the nav-bar, not just the part that fits the page. Here's what I mean (Watch the nav-bar): http://gyazo.com/513ad98520c9821c1de640b8c1d28fdd
Do you see how I'm unable to scroll to see the rest of the navbar items when width is decreased? When I don't have the nav-bar set to fixed, it works just fine (But I need it to follow the top of the page, as to why It's fixed).
Here's some of my navbar CSS:
nav{
min-width: 900px;
position: fixed;
background-color:white;
width: 100%;
}
nav img{
display: block;
margin: 0 auto;
width: 25%;
padding-top:5px;
padding-bottom: 15px;
}
nav li{
font-size: 11px;
text-transform: uppercase;
letter-spacing: 2px;
display: inline-block;
padding: 10px 50px 0px 10px;
}
nav a{
color: white;
text-decoration: none;
}
nav ul{
margin: 0;
height: 30px;
background-color: black;
}
And here's the full webpage (Yes, I know I need to make the images smaller.)
http://cydronixweb.kkhorram.info/
Strictly hypothetically speaking you first start with a media query . something like :
#media only screen and (max-width : 768px) {
}
now inside the media query you change some styles like :
#media screen and (max-width : 768px){
/*Make dropdown links appear inline*/
ul {
position: static;
display: none;
}
/*Create vertical spacing*/
li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
ul li, li a {
width: 100%;
}
/*Display 'show menu' link*/
.show-menu {
display:block;
}
}
since you've tagged the question only HTML and CSS .
here's the best resource on the web to create a CSS only , fully responsive menu.
Thank you.
Alexander .
This is a simple fix:
Add min-width: 100%; to body
That just ensures you don't get weird scrolling.