From other device or replit webview my website looks horrible
https://replit.com/@TasosKhatzes/my-house?v=1
Can you present a screenshot of what it looks like for you?
I believe the issue is that your website is not mobile compatible, you need to make it so the website fits on smaller screens as it does on big screens. I’m not a CSS wizard so I can’t help you here exactly, but I’m sure someone else can.
Okay! Thank you very much!
This page should help you create a responsive navigation bar with CSS…
I was able to improve your site for medium-screen devices, for large devices you can add a break-point to change the selective properties per will.
Here are some tips as per changes I made:
- Always use
em
orrem
for font size. - Always make a wrapper and apply collective properties only to wrapper, Your html code was:
<div class="nav-bg"></div>
<div class="nav-links">...</div>
<img src="images/house-logo.png" class="logo">
Here’s the improved version of the code:
<div class="nav-wrapper">
<img src="images/house-logo.png" class="logo">
<div class="nav-links">...</div>
</div>
I applied background properties to nav-wrapper
and removed nav-bg
and position:fixed
from other classes. nav-wrapper
css:
background-color: rgba(0,0,0,0.7);
/*rgba uses an extra property `a` at the end(4th value) to set opacity and hence we removed opacity protperty*/
width: 100%;
height: 5%;
position: fixed;
top: 0px;
left: 0%;
justify-content: space-between;
display:flex;
-
Instead of aligning each element seperately use wrapper to align the elements. For ex. I replaced properties like
top:1%; right:25%;
withmargin-top:1%; right:1em;
and instead I addedjustify-content: space-between
anddisplay:flex
to wrapper. -
I also saw that you had large gaps between links, so I changed
margin-left: 20%
in links tomargin-left: 2%
. If you wantmargin-left:20%
on large devices, add a break-point using media-queries in css. -
Added
width: 100%
tonav-links
wrapper so that links can properly fit in space; Changedheight: 5%
in.logo
toheight:100%
since now height was relative tonav-wrapper
which was already set toheight:5%
.
Here’s the final result:
https://replit.com/@abncodes/Shoinias-House
You might’ve encountered unfamiliar properties in my explanation, I recommend to look them up on w3schools.com.
Note: I made mobile first approach here, where I designed the site for medium/mobile devices first and asked you to add breakpoints for larger screens. You can inverse the technique used here as per your convenience.
IMPORTANT
You can also add a break-point for mobile devices so that nav looks good on mobile too but it’s not recommended. I instead recommend to totally hide this navbar on mobile and code a different one similar to this:
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.