Kosimus
Kosimus

Reputation: 38

Element extending beyond their defined width

I am trying to get my top menu to be exactly full width of the screen at all times. Sadly, while it works OK on desktop, it keeps extending beyond the expected width when on mobile.

To give some context: I'm trying to build a child theme of the "Rookie" theme (https://wordpress.org/themes/rookie/). My goal at this point is to replace the default menu of the theme with a top bar, on which I want the burger menu on the left, logo in the middle and the search button on the right.

This is already done, but for a reason I do not understand, when testing on mobile, the top bar is exceeding the expected 100% width. This can be observed when trying with "Phone 6/7/8" of the Chome dev tools. I also tried with a physical device and got the same result. The page is https://gornik2.kosimus.eu/

Picture from the dev tools

I spent several hours trying to figure it out and I essentially ran out of ideas at this point. I defined the width to 100%, 100vw and so on, tried max-width, checked parent elements and made sure that the width is not increased anywhere.

Pretty sure there is something incredibly stupid and small I am missing. Ideas would be greatly appreciated.

Thanks!

PS There is a bunch of other issues as well on that page (colors etc. - please just ignore those).

/* Make sure that the header is full-width */
.site-header {
    width: 100%;
}

#masthead {
    width: 100%;
    }

/* Get rid of the horizontal unordered list menu. Always use the mobile-like hamburger menu. */
.main-navigation ul {
    display: none;
}

.main-navigation.toggled .nav-menu {
    display: block;
    background: #000000;
}

.main-navigation li {
    float: none;
}

/* Menu bar to the top */
.main-navigation {
    display: block;
    position: fixed;
    top: 0;
    height: 65px;
    width: 100%;
}

/* As the top bar is 65px high, the open menu should have exactly that margin, so that they don't overlap */
.main-navigation.toggled .nav-menu {
    margin-top: 65px;
}

/* Display navigation over other stuff */
#site-navigation {
    z-index: 100;
}

/* Top bar styling */

/* Hamburger menu */
.main-navigation .menu-toggle {
    /*Send the whole button to the left*/
    display: inline-block;
    width: 20vw;
    height: 65px; /* Set the height of the whole top bar to 65 pixels */
    background: #ffffff;
    position: fixed;
    top: 0;
    left: 0;

}

.main-navigation .menu-toggle .dashicons {
    display: inline-block;
    color: #000000;   
    position: relative;
    left: 27%; /*Required to be positioned properly on the white bg*/
    font-size: 4rem;
    vertical-align: baseline;
}

/*White BG for the hamburger button*/
.main-navigation.toggled .menu-toggle {
    background: #ffffff;    
}

/* We're using the full screen search from a plugin, so the field here is not necessary */
.main-navigation .search-form .search-field {
    display: none;
}

/* Search button */
.main-navigation .search-form .search-submit {
    display: inline-block;
    width: 20vw;
    height: 65px;
    background: #ffffff;
    color: #000000;
    position: fixed;
    top: 0;
    right: 0;
    padding: 8px 16px;
}

.main-navigation .search-form .search-submit:hover {
    background: #ffffff;
    color: #000000;
}

.main-navigation .search-form {
    display: inline-block;
    margin: 0;
}

.main-navigation {
    background-color: #1a754a;
}

/* Logo centering and styling */
.site-branding {
    display: inline-block;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: calc(50% - 32.5px);
    z-index: 110;
}

.site-logo {
    margin: 0px;
    float: none;
}

.site-logo img {
    max-height: 65px;
}

.site-content {
    margin-top: 65px;
}

Upvotes: 1

Views: 51

Answers (1)

Sheik_ZM
Sheik_ZM

Reputation: 51

The pseudo element (:after) added to th tag of the LEAGUE TABLE is causing this issue. This issue can be fixed if the position value changed from "absolute" to "relative".

.sp-data-table .sorting:after {
      content: "\f156";
   color: transparent;
   /* position: absolute; */
   position: relative;
} 

Screenshot

Upvotes: 1

Related Questions