Image fills up the whole space on Safari mobile - css

So my site's navbar shows up differently on Android and iOS phone, on Chrome/Android it looks fine but for some reason, the hamburger icon got stretched out and covers the whole page on Safari/iOS.
I use TailwindCSS and here's my code:
<nav className="fixed sticky top-0 z-10 flex gap-2 p-2 bg-white cursor-pointer md:pl-4">
<img
onClick={toggleOpen}
src="/hamburger-menu-red.png" className="w-10" alt="menu"
/>
{props.showLogo && (
<Link to="/">
<img
src="/cooken-logo.png" alt="cooken-logo" className="w-20 cursor-pointer" />
</Link>
)}
</nav>
Is it because I don't specify the height of the hamburger icon or is it some compatibility issue with Safari? Any help would be greatly appreciated.
Update based on Seth's input
<nav className="fixed sticky top-0 z-10 flex items-center h-12 gap-2 p-2 bg-white md:pl-4">
<button
onClick={toggleOpen}
>
<img
src="/hamburger-menu-red.png" className="w-10 h-8" alt="menu"
/>
</button>
{props.showLogo && (
<Link to="/">
<img
src="/cooken-logo.png" alt="cooken-logo" className="w-16 h-8"
/>
</Link>
)}
</nav>

Because it is the child of a flex item and the default align-items property of flex items is stretch.
However, there are other issues that are more of concern with your code, it is invalid. Neither an image of a hamburger or a site logo are justifiable nav items. A nav element should contain navigation links to site pages.
You should not attach a click event to an image. An image element is just for showing an image, nothing else. If it goes somewhere use a link, if it does something use a button element.
You don't need to put cursors on links, they already have them; images don't because they are not interactive elements.
I would suggest that the best approach is to use a button elemement (which already comes with clicky behaviours built in) to reveal a list of links (which come with linky behaviours built in).

Related

Second Vertical (Y axis) scroll Bar, cant remove it without removing snap effect

in my nextjs 13.1 website using the new app directory and tailwind css, I have the snap effect on each section of my SPA, with my current code, the snap works, but i then get a second vertical scrollbar. if i remove overflow-y-scroll and put in overflow-y-hidden, of course this does remove the second scrollbar, but then my snap doesnt work. I have tried auto, but cant seem to only have 1 vertical scrollbar with the snap effect. Here is my page.jsx code:
`export default function Home() {
return (
{/* Header in Layout /}
{/ Header */}
{/* Hero */}
<section id="hero" className="snap-start">
<Hero />
</section>
{/* About*/}
<section id="about" className="snap-center">
<About />
</section>
{/* Work Experience */}
<section id="freelance" className="snap-center">
<FreelanceWork />
</section>
{/* Practice Projects */}
<section id="projects" className="snap-start">
<PracticeProjects />
</section>
{/* Skills */}
<section id="skills" className="snap-start">
<Skills />
</section>
{/* Contact Me */}
<section id="contact" className="snap-center">
<ContactMe />
</section>
</div>
);
}`
and if it helps, as an example in every component, generally speaking i have a div wrapping every component with this: <div className=" h-screen flex flex-col relative mx-auto text-center items-center md:text-left md:flex-row max-w-7xl px-10 justify-center">
so not sure if i have to add something to each div to make this work. Thanks!
i tried playing around with different overflows but i couldnt get it to work without losing snap effect

Why is my line-clamp is not working with fixed height on Safari browser?

I have a list of episodes that I want to have a fixed height. I tried to line-clamp-2 for the episode title that has text that is longer than 2 lines.
Everything is working on my normal PC view, even if I open Dev Tools and view it as device view, it still displays as I want, but after I use my real phone, which is iPhone to view it, it has a problem which I wasn't expecting at all because there's none when I was CSS it on my PC.
What I did, I set every episode item of mine to fixed 70px height, have 12px padding to left and right, and 0.25rem padding for top and bottom. I tried the solution like this post: line clamp (webkit) not working in safari
Which is to put the overflow-hidden and line-clamp to the div instead of the actual p tag, and in the p tag using the inline display, but in my case, it is not working.
I'm using a tailwindCSS to CSS my component in React. Here's how I tried so far:
<div className="lg:h-[calc(100vh-60px)] overflow-y-scroll bg-[#222] h-[30vh] max-lg:mb-[20px]">
{listEpisode.map((item, i) => (
<Link
to={`episode-url`}
key={i}
className="w-full h-[70px] px-[12px] leading-normal
py-1 hover:text-white hover:opacity-80 hover:bg-white/20
duration-200 ease-in-out line-clamp-2 overflow-hidden
odd:bg-[#111111] even:bg-[#272727]"
>
<p className="inline after:whitespace-pre">
{item.title}
</p>
</Link>
))}
</div>
The result I get when in Dev Tools on Chrome, I set viewpoint to iPhone 6/7/8 (because I'm using iPhone 7, too)
PC with device viewpoint (working as expected):
On the actual device using safari - mine is iPhone 7 (which is not working as I expect it to be):
I don't know what's the cause of this, so I can't come up with a solution to fix it, because it was normal on PC.
I've managed to handle this through test here and there a bit around my CSS.
I change a little bit how I style it. First, I set my a tag as a flex and set a fixed height for it (I change my fixed height to 80px, looks better for me), with padding, and margin stuff around the a tag and my a tag is the parent element, then inside, I wrap my paragraph p tag inside a div, I
don't set that div to have any height, so it'll take auto height, inside a div, which now is a paragraph, I finally set it to line-clamp-2 directly.
Here's the result that I have now on my device, the PC is always working fine:
Note: I have 2 div inside the a tag because I changed my mind on how to make it suit my liking, and that's why I have some div that has flex, you might not need it, but I hope those who have the same problem get an idea.
This is my Tailwind CSS:
<div className="lg:h-[calc(100vh-60px)] overflow-y-scroll bg-[#222] h-[30vh] max-lg:mb-[20px]">
{listEpisode.map((item, i) => (
<Link
to={`episode-url`}
key={i}
className="flex items-center h-[80px]
px-[12px] py-[8px] w-full hover:text-white
hover:opacity-80 hover:bg-white/20 duration-200 ease-in-out"
>
<div className="mr-[6px] h-full flex items-center justify-center text-amber-400 ">
<p className="font-extrabold px-[4px] border-r-[2px] opacity-80">
{i+1}
</p>
</div>
<div className="mx-[6px] w-full flex">
<p className="line-clamp-2 w-full text-[#E2DFD2]">
{item.title}
</p>
</div>
</Link>
))}
</div>

Tailwind background images bouncing around on mobile

I've encountered an annoying problem with Tailwind CSS on Nuxt3. Whenever I'm on mobile, the browser's nav menu causes the bg image to jump around, i.e: when the bottom navbar comes up for my mobile browser it causes the bg image to jump up (and jump down when it retracts).
Is there any way to tell mobile browsers I want the bg image to stay put?
The layout template:
<template>
<div class="w-full min-h-screen
bg-offblack
text-milk">
<div class="min-h-screen
overflow-y-auto overflow-hidden
grid grid-rows-1 grid-cols-1
justify-items-center
bg-fixed bg-right-bottom bg-no-repeat bg-[url('~/assets/images/ui/decker_mobile.png')]
md:grid-cols-2
lg:bg-[url('~/assets/images/ui/decker_desktop.png')]">
<slot />
</div>
</div>
</template>

Web App Default Layout hides the bottom NavBar

I have been building a responsive Web Application that on loading with an address bar hides the bottom-most navbar. Is there a way to load it with the entire layout?
Here's how it should load:
But here's how it loads on a smartphone:
However, when I scroll a little, it appears exactly as I want it to be:
I have used flex display as shown below: [I am using tailwind along with React JS]:
<div className='flex flex-col justify-around w-screen h-screen align-center'>
{topNavBarprops ? (
<TopNavBar {...topNavBarprops} />
) : (
<TopNavBar headerText={'Unverified Account'} />
)}
<div className='flex flex-col flex-auto max-h-screen overflow-auto'>
{childComponent}
</div>
<BottomNavBar />
</div>
Your body/content div is too tall, likely pushed down by the top navbar, to resolve this, you can set the height value of the body/content div to be calc(100vh - height of navbar here)

Problems styling MaterialUI Accordion heading

https://codesandbox.io/s/tailwindcss-react-boilerplat-forked-7yrez?file=/src/components/app.js
im having problems with the styling in my Accordion Heading.
I set my Accordion Contents like this:
<Accordion
heading1= { <DishItem name="Döner Teller Spezial" price="13,60€"/> }
content1= { <AccordionContent /> }
</Accordion>
However, the way my flex-row is styled within my DishItem component (working without issues on other places, or tested by itself on tailwindplay.com) seems to break within the Accordion Heading and im not sure how to fix it.
This is my DishItem Component:
<div className="w-full">
<div className="flex flex-row py-2 bg-white">
<div>
<p className="pl-2 leading-none font-lato">{props.name}</p>
<p className="pl-2 text-base leading-none"> { props.zusatz }
</div>
<p className="m-2 ml-auto place-self-center"> 24,50€</p>
</div>
</div>
This way of pushing the last flex element to the end of the container worked fine, but not within the heading. I am new to using materialUI and would appreciate any help to fix this.
The problem mostly comes from:
<AccordionSummary aria-controls="panel1a-content" id="panel1a-header">
<Typography className={classes.heading}>{props.heading1}</Typography>
</AccordionSummary>
Typography adds a <P> tag to your content and that's making it impossible for you to stretch the content. You could also make your life much easier by using the <Grid> component from Material-UI.
See my sandbox: https://codesandbox.io/s/tailwindcss-react-boilerplat-forked-5yv3w?file=/src/components/Accordion.js

Resources