Using "overflow-x: hidden" is ineffective on mobile devices

I'm facing an issue where the CSS property overflow-x: hidden is not working on mobile devices.

Here is a snippet of my HTML code:

<div class="topbar">
    <div class="navbar-brand float-left">
        <a href="#"><img src="assets/img/logo.png"></a>
    </div>
    <div class="float-right mr-4 menu-bar">
        <a href="#about"><span class="a-border" onclick="menuclick(this)">ABOUT US</span></a>
        <a href="#creater"><span class="a-border" onclick="menuclick(this)">CREATERS</span></a>
        <a href="#news"><span class="a-border" onclick="menuclick(this)">NEWS</span></a>
        <a href="#contact"><span class="a-border" onclick="menuclick(this)">CONTACT</span></a>
    </div>
    <div class="dropdown-btn">
        <div class="menu_btn" onclick="event.stopPropagation(); myFunction(this)">
            <div class="bar1"></div>
            <div class="bar2"></div>
            <div class="bar3"></div>
        </div>
        <div id="myDropdown" class="dropdown-content">
            <a href="#about"><span class="a-border" onclick="menuclick(this)">ABOUT US</span></a>
            <a href="#creater"><span class="a-border" onclick="menuclick(this)">CREATERS</span></a>
            <a href="#news"><span class="a-border" onclick="menuclick(this)">NEWS</span></a>
            <a href="#contact"><span class="a-border" onclick="menuclick(this)">CONTACT</span></a>
        </div>
    </div>
    <div class="menu-img"><img src="assets/img/menu-img.png"></div>
</div>

Here's a snippet of my CSS:

.topbar {
    width: 100%;
    background-color: black;
    color: white;
    margin: 0px;
    padding: 3rem;
    position: relative;
}
a {
    text-decoration: none;
}
/* Other CSS styles... */

I've tried using overflow-x: hidden on body and html, but it didn't work as expected. When I applied it directly to topbar, it worked but caused the dropdown menu to disappear. I'm looking for a solution to hide overflow on the image but still show the dropdown menu.

Answer №1

I attempted it in this manner.

<div class = "topbar">
    <div class="navbar-brand float-left">
        <a href="#"><img src="assets/img/logo.png"></a>
    </div>
    <div class="float-right mr-4 menu-bar">
        <a href="#about"><span class="a-border" onclick="menuclick(this)">ABOUT US</span></a>
        <a href="#creater"><span class="a-border" onclick="menuclick(this)">CREATERS</span></a>
        <a href="#news"><span class="a-border" onclick="menuclick(this)">NEWS</span></a>
        <a href="#contact"><span class="a-border" onclick="menuclick(this)">CONTACT</span></a>
    </div>
    <div class="dropdown-btn">
        <div class="menu_btn" onclick="event.stopPropagation(); myFunction(this)">
            <div class="bar1"></div>
            <div class="bar2"></div>
            <div class="bar3"></div>
        </div>
        <div id="myDropdown" class="dropdown-content">
            <a href="#about"><span class="a-border" onclick="menuclick(this)">ABOUT US</span></a>
            <a href="#creater"><span class="a-border" onclick="menuclick(this)">CREATERS</span></a>
            <a href="#news"><span class="a-border" onclick="menuclick(this)">NEWS</span></a>
            <a href="#contact"><span class="a-border" onclick="menuclick(this)">CONTACT</span></a>
        </div>
    </div>
    <div class="menu-img"></div>
</div>

css

.menu-img {
    background-image: url("assets/img/menu-img.png");
    background-size: 100% 100%;
    position: fixed;
    top: 0;
    right: -5rem;
}

I believe that img cannot be hidden, however a background image can be concealed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to remove bootstrap when transitioning to a new microfrontend?

Our team is facing an issue with styling when using a combination of React, Bootstrap, and Tailwind. The problem arises when linking our micro frontend to modules that use Tailwind, as the Bootstrap styles persist despite the change. Since both Tailwind an ...

How can the color of the <md-toolbar> be customized?

Here is a glimpse of how my code appears on CodePen: I am aiming to have the background color of "Sidenav Left" match that of "Menu Items", which is designated by the class .nav-theme { background-color: #34495E } I attempted to override it like this ...

Centering the scrollIntoView feature on mobile devices is presenting challenges with NextJS applications

Description While navigating on mobile browsers, I'm facing a challenge with keeping an element centered as I scroll due to the browser window minimizing. I've experimented with different solutions such as utilizing the react-scroll library and ...

Unable to reveal hidden text with invisible formatting (font-size: 0)

I have a Joomla 3 website where I created a blog using a design-controll template. I made a "new-article" page but realized that some buttons were missing text. Upon inspecting with Firebug, I found that there was a font-size:0 property causing this issue. ...

Determine the width of the window and adjust the positioning of jQuery UI tooltips accordingly

Struggling to adjust the jQuery UI tooltip position based on screen width, but can't seem to figure it out. Can someone assist me in detecting the browser's width and changing the tooltip position accordingly? [fiddle] $(function () { $(doc ...

Can you restrict the selection of text to only the current element?

<div class="container"> <div class="item1">text text text in div element 1</div> <div class="item2">text text text in div element 2</div> </div> Is there a way using HTML nodes, CSS, or JavaScript to restrict the select ...

Issues with aligning text in TextBoxes

I'm struggling to center align my text boxes and write labels on either side. I want it to look like this: https://i.stack.imgur.com/6QsNv.png Despite trying different solutions, I can't seem to get the boxes to align in the center. Is there a ...

The two divs are positioned on top of one another, with the link in the bottom div being unclickable

I am trying to create a unique effect where a tile divides into two on hover, with each tile acting as an individual link. Additionally, I want the background color of the tiles to change on hover. To achieve this, I have stacked two divs (toptile and bot ...

Maximizing Bootstrap: Enabling dual dropdown options side by side on a single row

I am attempting to design a login form within a Bootstrap navbar dropdown. My goal is to have the bottom item display two items side by side in the same row (login/register), but I am struggling to achieve this. You can view what it currently looks like h ...

Ways to determine the height of a row within a flexbox

Is it possible to obtain the height of each row within a flexbox container using JavaScript? For instance, if there are 3 rows in the container, can I retrieve the height of the second row specifically? ...

"Repetitive" elements arranged horizontally

My goal is to create a looped row of elements, similar to this design: https://i.sstatic.net/7cC2z.png This row should function like a carousel where clicking the "Next" button changes the current element and positions it in the center of the row. I envi ...

Adjusting the background color of an individual element within a grid using CSS

<div id="56c46f8385953" class="mg_box mg_pre_show col1_3 row1_3 m_col1_2 m_row1_3 mgi_14 mg_pag_1 mg_gallery mg_transitions mg_closed " rel="pid_14" mgi_w="0.333" mgi_h="0.333" mgi_mw="0.5" mgi_mh="0.333" > <div class="mg_shadow_div"> ...

Incorporating rounded corners to an embedded YouTube video

Check out this JSFiddle link. The border-radius property appears to be working correctly at first, but then the rounded corners suddenly disappear shortly after loading. Is there a way to apply rounded corners to YouTube videos that are embedded on a webp ...

Create a sleek 2-column design featuring a bonus scroll bar exclusively using CSS styling

In my current project, I have a unique challenge. I am working with a list of flattened div elements and unfortunately, I am unable to edit the HTML markup to add any structures. The first div in the list is quite long, and I would like to place it in a se ...

Adding an image within the body of text in a Django model, where both the text and image coexist

I am currently seeking a method to seamlessly insert an image within the text of my Django-powered blog. My goal is to achieve a layout similar to the one showcased in this example: https://i.stack.imgur.com/cFKgG.png The desired layout consists of two c ...

What could be causing my grid-area properties to not take effect?

I'm attempting to create a basic structure with a header in the top row, menu and content in the middle row, and footer at the bottom. Here is what I have so far: body { color: white; } .container { background: cyan; display: grid; ...

What are the steps for editing and preserving a logo with an 8-bit indexed color palette?

After purchasing a RE/MAX franchise, I now need to make edits to the official logo found on remax.com using Adobe Photoshop. However, I have encountered a problem when trying to edit their logo in Photoshop. When I open their PNG logo, the layer appears d ...

applying different styles to various elements

As a newcomer to the world of jQuery, I am attempting to achieve the following goal: I have several instances of a div, and for each instance, I randomly assign a class from a predefined list in order to modify certain attributes. While this process is su ...

Validating HTML forms using Javascript without displaying innerHTML feedback

Hey, I'm just diving into web development and I'm struggling to figure out why my innerHTML content isn't displaying on the page. Can anyone offer some assistance? I'm trying to display error messages if certain fields are left empty, b ...

What is the best way to incorporate Ekko Lightbox into an Angular 7 Project?

I'm facing an issue while implementing Ekko lightbox in my angular project. Specifically, I want to use it in a certain component but I am unsure about how to import the necessary files into that component. After installing Ekko via NPM, I found all ...