expanding menu options in a dynamic design

My webpage features a logo alongside a menu:

Here's the HTML code:

<div id="logomenuwrapper">
<div id="logo"><img src="img/logo_light.jpg"/></div>
<div id="menu">
    <ul>
        <li><a href="#">About</a></li>
        <li class="notfirst"><a href="#">Work</a></li>
        <li class="notfirst"><a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="630e02021117060d23000c07">[email protected]</a>?subject=Hello">Contact</a></li>
    </ul>
</div>
</div>

This is the CSS styling applied:

#logomenuwrapper{overflow:hidden;}
#logo
{
    padding-right:1.2%;float:left; max-width:100% !important;
    max-height:100% !important;
    display:block;
}
#menu{float:left;padding-left:1.2%;font-size:0.875em;border-left:1px solid #ea4a4a;}
#menu ul li.notfirst
{
    padding-top:0.3225em;
}

I have implemented media queries to adjust the menu font size on smaller screens.

However, I'm facing an issue where the menu becomes smaller than the logo. How can I make the logo scale proportionally with the menu? I've already added the following CSS rule:

img {max-width:100%;}

Shown below is an example of how it appears on a smaller screen (notice the oversized logo):

Answer №1

Consider adjusting your media queries like this:

@media screen and (max-width: 800px) {
    body {
        font-size: 85%;
    }
    #logo img {
        width:84%;
    }
}
@media screen and (max-width: 400px) {
    body {
        font-size: 75%;
    }
    #logo img {
        width: 75%;
    }
}

Also, modify #logo to something similar to this:

#logo {
    padding-right:12px;
    border-right:1px solid #ea4a4a;
    float:left;
}

View Demo Here

Note: Ensure that you place

@media screen and (max-width: 800px)
before
@media screen and (max-width: 400px)
as shown above.

Refer to Importance of Media Query Order in CSS for more insights on organizing media queries effectively.

Answer №2

Although it may not be the most semantic solution, have you investigated the possibilities of scalable text with FITTEXTJS

By utilizing javascript, FITTEXTJS allows for dynamic scaling of text. While you already have a resolution for images, it seems like the issue lies within the text itself. Using media queries to set break points is one approach, but it may not achieve the fluidity you desire. I will update my post with a demonstration on Fiddle after my workout at the gym. Just wanted to share this potential solution in case it proves to be useful.

Answer №3

To ensure your images scale properly, adjust the width of the image wrapper (#logo in this case) within the mediaqueries or set it globally using percentages (refer to jsfiddle link for example).

Don't forget to include max-width: 100%; for all images.

img { max-width: 100%; }

#logo { 
    width: 14%;
    // you can remove max-width:100 as it is not necessary.
    ...
}

For a demonstration, visit this JSFiddle link and resize your browser window.

Answer №4

It seems like the approach you're taking may not be the most effective. Shrinking text when the screen size is smaller might not be the best solution, especially for mobile devices where touch targets need to be easily clickable. Instead of reducing the text size, consider adding padding or margin to improve the touch target without visually shrinking the menu.

One alternative could be stacking the navigation below the logo on smaller screens and then shifting it next to the logo as the screen size increases. This approach avoids having to adjust text or image sizes while optimizing the design for small screens.

If you'd like, I created a demo for you: Demo Link. Make sure to view the full preview to see how the new menu behavior works when resized.

For the smallest viewport size, you could choose any layout pattern that suits your needs. A simple stacked layout works well for your current menu structure, but you might want to consider an accordion or off-canvas menu if your navigation grows in the future.

For additional insights, you can read Chris Coyier's article on designing for tablets and Trent Walton's post about typography and touch interactions.

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

Limiting the character input in ion-textarea within Ionic 2: A step-by-step guide

In my Ionic 2 application, I need to limit user comments to less than 500 characters in a text area. What is the best way to implement this restriction? ...

Accumulation of style from various directives in AngularJS on a single element

Currently, I am working on developing a component framework and find myself in need of a method to apply styles from multiple directives to an element in a way that they can accumulate. The priority of the styles should be determined by the directive creat ...

Using a restricted set of special characters in a jQuery regular expression

My requirement is to only allow alphanumeric data along with the following special characters: ' (single quote) - (hyphen) . (dot) single space I attempted this approach: var userinput = $(this).val(); var pattern = [A-Za-z0-9_~\-!@#\$% ...

The Next.js application is unable to load the combined CSS from a React Component Toolkit

My React components repository includes individual .css files for each component which are imported into the respective components. These components are then bundled using a rollup configuration and published as an NPM package, with all component CSS being ...

Generating a dynamic triangle within a div while ensuring it fits perfectly with the maximum width

I need help with creating a responsive triangle on a web page that takes three inputs. The challenge is to adjust the size of the triangle so it fits inside a div element while maintaining the aspect ratio of the inputs. For instance, if the inputs are 500 ...

Discovering the meeting point where two dives converge

Is there a method to change the color of the overlapped common part of two animated circles? ...

How can I create a one-column layout in CSS grid where one element automatically fills the remaining space after the other elements have taken their own auto widths?

I want a flexible layout with auto width columns for future additions. Avoiding extra wrappers is preferred. CSS grid is the preferred method over flexbox (although flexbox can achieve it with wrappers). This layout is intended for a navigation bar Here&a ...

Is it possible for JavaScript to identify modifications in the HTML, like an input made with Ctrl+Shift+I?

Check out this website I'm currently working on. As a fun challenge for users, we're encouraging them to use ctrl+shift+i to manipulate the HTML and modify certain elements. Is it possible for Javascript or CSS/HTML to detect these changes? For ...

Arranging a div's position in relation to an unrelated div

I need to position a div element called "a" below another div element known as "b". The HTML code has the following structure: <div id="a"></div> <form> <div id="b"></div> <div id="c"></div> </form> U ...

Automatically add shimmer with CSS styling

Is it possible to make the shine effect work automatically (without needing hover) every 5 seconds? http://jsfiddle.net/AntonTrollback/nqQc7/ .icon:after { content: ""; position: absolute; top: -110%; left: -210%; width: 200%; height: 200%; ...

Tips for optimizing the placement of div elements for top advertisements on Amazon's website

I'm looking to overlay some divs on top of Amazon.com ads, similar to the image above. This is part of a personal project where I need to position these divs precisely over the ads. To achieve this effect, I've been using getBoundingClientRect t ...

Conceal the object, while revealing a void in its place

Is there a way to hide an image but keep the containing div blank with the same dimensions? I want it to appear as if no content was there, maintaining the original width and height. For example: http://jsfiddle.net/rJuWL/1/ After hiding, "Second!" appea ...

Scrapy and Python data gets corrupted by <br> tags causing issues

As I attempt to extract the text from Amazon reviews using scrapy, I encounter an issue. Reviews with multiple lines have their text separated by "< br >" tags within a span element. So, when I try to scrape the first review, I use this line of code: r ...

Confirming user credentials for every page

I am currently working with an HTML page that includes front end PHP for server side scripting. One issue I have encountered is the configuration page, which can be accessed by disabling JavaScript in Mozilla settings. My current validation method relies ...

What could be causing my CSS to not display properly on GitHub Pages?

Currently working on a web-based game project called Sweet Shoppe, and utilizing GitHub Pages for hosting. However, encountered an issue where the CSS does not seem to be functioning properly on GitHub Pages. Attempted placing the CSS file in the main rep ...

Permit users to access downloads upon authorization

Hey there, just a quick question. I'm in the process of building a website that stores files and allows users to purchase and download them. The issue I'm facing is that the file directory is protected with .htaccess permissions to prevent unauth ...

Deactivate the focus state when hovering over different items in the navigation bar

Currently facing an issue with my Navbar items having underline animation on hover. Once clicked, the animation persists. However, when hovering over a neighboring navbar item, the underlines appear next to each other, creating the illusion of one long lin ...

Tips for halting click propagation in VueJS

My dilemma lies within a recursive list (tree) where each element contains a @click="sayHello(el.id)". The challenge arises due to the nested structure of the list, such as: list-element-0-01 ├──list-el-1-01 │ └──list-el-2-01 └──list ...

The positioning of the menu icons varies

When it comes to displaying the search icon in the WordPress toggle bar, I use a custom JavaScript file. This setup is mainly focused on website design and menu functionality. Additionally, I have integrated a newsletter subscription plugin for managing su ...

What steps can I take to ensure that an image does not exceed the size of its parent tag?

Is there a way to ensure that items placed in a container do not exceed the boundaries of the container? I am trying to use my logo as the home button, but when I set the image height and width to 100%, it becomes larger than the nav bar. The CSS for the n ...