Making the website more compact results in expanding its breadth

I am facing an issue with my YouTube-style header in CSS. When I resize my website, the width of the header expands and my icons go beyond the boundaries of the site. However, when I try the same thing on , its width does not increase no matter how small you make it. Any suggestions on why this is happening? I want to avoid using overflow:hidden; as it cuts out my icons when the website size is reduced, but I still want the icons to be visible like in the YouTube mobile version.

Here's a link to test it out: https://codesandbox.io/s/material-ui-icon-avatar-example-forked-exzhzj?file=/src/app.css&resolutionWidth=153&resolutionHeight=671

Code:

import React from "react";
import ReactDOM from "react-dom";
import { makeStyles } from "@material-ui/core/styles";
import Avatar from "@material-ui/core/Avatar";
import NotificationsIcon from "@material-ui/icons/Notifications";
import MenuIcon from "@material-ui/icons/Menu";
import SearchIcon from "@material-ui/icons/Search";
import VideoCallIcon from "@material-ui/icons/VideoCall";
import AppsIcon from "@material-ui/icons/Apps";
import "./app.css";

export default function EmailAvatar() {
  return (
    <div className="box-container">
      <div className="header">
        <div className="header__left">
          <MenuIcon />
          {/* <img
            className="header__logo"
            src="https://upload.wikimedia.org/wikipedia/commons/e/e1/Logo_of_YouTube_%282015-2017%29.svg"
            alt=""
          /> */}
        </div>
        <div className="header__input">
          <input placeholder="Search" type="text" />
        </div>
        <div className="header__icons">
          <span title="Create">
            <VideoCallIcon className="header__icon" />
          </span>
          <span>
            <AppsIcon className="header__icon" />
          </span>

          <span title="Notifications">
            {" "}
            <NotificationsIcon className="header__icon" />
          </span>

          <Avatar
            alt="Remy Sharp"
            src="https://www.shutterstock.com/image-photo/skeptic-surprised-cat-thinking-dont-260nw-1905929728.jpg"
          />
        </div>
      </div>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<EmailAvatar />, rootElement);

Image of the problem:

https://i.sstatic.net/GcJuo.png

YouTube mobile view for reference:

https://i.sstatic.net/3eKZk.png

Answer №1

adding overflow:hidden

.header {
  add: hidden;
}

Answer №2

It seems like your header is contained within another element with a sticky position. To resolve this, update the CSS for your header class as shown below:

.header {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
}

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

The StereoEffect is unable to render the texture from the WebGLRenderTarget

I am looking to blur a panoramic view to create a user-interface in front of the blurred view. To achieve this, I am using a fragment-shader-based implementation to compute the blurred image on the client side. Everything works perfectly when using the re ...

Perl's powerful capabilities allow for the creation of interactive drop-down menus

As a newcomer to web programming, I have recently been tasked with scripting projects during my summer internship. I've been utilizing Perl to develop CGI scripts for my company's internal website, specifically catering to the needs of the develo ...

Working with JavaScript and making AJAX calls to interact with PHP backend

Having trouble with this code, it's not working as expected. I want to pass the value when I select an option from the dropdown menu, process the data using onChange event and display the value in the tag. <label for="headmark" class="lbl-ui selec ...

Is there a way to connect two circles with identical numbers using Javascript and HTML?

My latest project involves creating a fun program that generates 4 balls on the screen, each with a unique number displayed inside. Users can input their desired values for new circles to be generated and then click a button to see four more balls appear ...

Suggestions for implementing maxWidth in the TextField component from mui?

I've been attempting to utilize maxWidth on the TextField component from material-ui, but I'm facing some difficulties. import * as React from "react"; import Box from "@mui/material/Box"; import TextField from "@mui/mate ...

Searching for an equivalent to AdRotator within the .NET framework

Currently, I am developing a website that features rotating testimonials. I am interested in finding a solution similar to the AdRotator class available in .NET. However, instead of rotating images, I need a method to rotate formatted text blocks using HTM ...

Problem with CSS/SASS dropdown navigation bar

Having trouble with a design issue, I have successfully recreated the Twitter navigation bar and now I want a dropdown menu to appear when hovering over the 'settings' text. However, I'm facing difficulties as the overflow is hidden in the n ...

Is there a way to prevent my array from shuffling when clicked?

Building a Quiz App using Next Js has been going smoothly until encountering an issue where the array keeps re-shuffling onClick of any button. Adding e.preventDefault on all button functions did not resolve the problem as it continues to reshuffle the arr ...

Include an element in a secondary list based on its position in the initial list

Having 2 lists presents a challenge. An Angular service is utilized with a splice-based method to remove items from the first list (named "items") according to their index through a ng-click action. service.removeItem = function (itemIndex) { items ...

I attempted to mock a standalone class method using jest.spyOn, but unexpectedly the real method was executed instead of the mock implementation

Programming Class //Class Definition class User { constructor(){ } getUserData(){ //performs an action without returning anything } } When a button is clicked within a react component, this method gets executed //ReactComponent.tsx handleButtonClick() { ...

I need either XPATH or CSS to target a specific checkbox within a list of checkboxes wrapped in span tags

I'm trying to find the XPATH or CSS locator for a checkbox in an HTML span tag that has a label with specific text, like "Allow gender mismatch". I can locate the label using XPATH, but I'm not sure how to target the input tag so I can click on t ...

Automate Cart Updates with Increment and Decrement Buttons on the Cart Page of Magento 2 Store

On the cart page, I've added buttons to increase (+) and decrease (-) the quantity of a product. How can I make it so that the quantity updates automatically without needing to click on the update shopping cart button? Any suggestions on how to solve ...

Ensuring the authenticity of dynamic forms

jQuery(document).ready(function(){ $("#submitButton").click(function () { if ( $("#formToSubmit").validationEngine('validate') == true) { $("#formToSubmit").submit(); } }); Utilizing the Validation Engine plugin for jQuery to valida ...

The text in Three.js fails to display

Hey there, I'm relatively new to Three.js and having some trouble getting basic text to render. Most of the solutions I found on StackOverflow seem outdated, so I thought I'd ask here. The code snippet below only results in a black screen. Any he ...

Is there a way to dynamically change the helperText of a Material UI TextField using its current value through code?

I'm currently attempting to dynamically change the helperText of a Material UI TextField based on the value entered into the field. Below is my current implementation: const defaultScores = { STR: 10, DEX: 10, CON: 10, INT: 10, WIS: 10, CH ...

Tips on sending template variables to JavaScript

Greetings, I am currently facing an issue with passing a template variable to javascript in order to create a chart. Unfortunately, Django treats all js files as static files which means that dynamic template variables are not accessible within javascript. ...

Creating a visually stunning landscape in Three.JS by rendering a detailed map using various texture atlas tilesets

Introduction: In my current project, I am using Three.JS (v95, WebGL Renderer) to render an isometric map that consists of various graphic tilesets. The specific tile is obtained through a TextureAtlasLoader and its position from a JSON file. Here's ...

What are the steps to create a "gooey glide" animation using React and MUI?

I am looking to create a unique animation for my list of items on a web page. My goal is to have the items slide in one by one with rapid succession and then slightly shrink once they reach their final position, similar to how pillows might fall or like a ...

Automatically update the border sample once the visitor enters a color code into the input text field

Is it possible to automatically change the sample border when a visitor enters a color code in the input textfield at: Do you have a specific border color in mind? input name="ContentInclude:borderspecs" type="text" maxlength="200" id="ContentInclude_bor ...

The art of replacing material-ui styles with styled components

As a newcomer to UI material design, I am eager to create my own customized Button Component using styled-components. I am facing a challenge in overriding the CSS based on different button variations such as "primary" or "secondary". You can find my cod ...