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

Using the jquery slider in conjunction with the onchange event

I have integrated a jquery slider add-on into my project that updates a value in a Linux file whenever it is manipulated. The slider is connected to a text input box, which is set as readonly and therefore always blurred. The issue I am facing is that the ...

What about a sliding element feature?

Is there a popular slider component that many startups are using, or are these types of sliders typically built from scratch? It seems like they are everywhere on startup websites. I would appreciate it if someone could point me in the right direction with ...

Retrieve the 'id' value located within the 'img' tag of HTML code by utilizing Beautiful Soup in Python

Given the following code snippet: id_image = soup.find_all("img")[2] print(id_image) The result is: <img id="nexperts-logo" src="images/nexperts.png"/> I am trying to extract and print only the id value, which is ...

Ways to change the CSS styles of components within App

When my app is in full screen mode, I need to increase the font size for certain components. Within my App.jsx file, I have a variable that adds the "fullscreen" class to the root DIV of the app when triggered. Instead of using a blanket approach like * ...

Tips for organizing the contents of nested items in alignment

Here's a layout I've created, you can view it on CodePen. .parent { display: flex; justify-content: space-between; } .left { flex-grow: 1; flex-basis: 0; background-color: blue; } .right { background-color: red; flex-grow ...

The makeStyles feature is currently not functioning properly in the latest version of Next.js with Material UI v5

Currently, I am utilizing nextjs along with material ui in my project "@mui/material": "^5.0.1", "@mui/styles": "^5.0.1", Below is the code snippet of my component structure import { AppBar, Toolbar, Typography, Box ...

Tips on showcasing information with ng for in Ionic 2

I am currently working on the thank you page for my project. When the success call is made, it will display both ORDER DETAILS and Delivery Details. However, in the event of a failure call, only the ORDER DETAILS are displayed. While the success call is f ...

Various image dimensions cause divs to shift unevenly

Here is the current setup: <div class="row"> <div class="col-md-4 content-column"> <img class="btn-center btn-desktop" src="images/buttons/btn-desktop.svg" alt="desktop button"> <h2 class="btn-deskt ...

Ways to make two blocks of text appear side by side and adapt to different screen sizes

Check out our website imageI'm facing a challenge in making these two text elements appear next to each other rather than stacking on top of each other. Additionally, I need them to adapt responsively to changes in screen size. When 'Icontext&ap ...

problems with verifying your domain in Google apps

I'm sorry for reaching out here instead of Google's forums, but I haven't had any luck finding answers there. Currently, I have a domain verified on Google Apps by uploading an HTML file, which is being used for email services. I don' ...

Displaying information from a database in an HTML form using PHP

Seeking assistance with managing data and populating: I'm in the process of creating an Employee database with two pages: 1. Add Employee 2. Modify Employee The "Add Employee" page requires input fields for EMP Name, EMP ID, Manager name (from a dro ...

Restoring the style on <a> renders it ineffective

Recently, I encountered an issue where the functionality of the <a> tag is lost when using this CSS code: a {all:unset;}. Does anyone have any suggestions on how to address this problem without completely avoiding the use of that particular code sn ...

access older siblings, accordion animation

I need assistance achieving an accordion effect on a DIV when hovering over it. The right side of the accordion is functioning properly, but I am facing issues with the left side. You can view my code on jsFiddle Could someone please provide guidance on ...

Navigate to the following div, navigate back to the previous div

I am attempting to implement a div navigation system with next/previous buttons. Despite searching extensively on Google, I have not found the exact solution I am looking for. First and foremost, I want to maintain the integrity of my html structure. < ...

Broken CSS dropdown menu issue

Recently, I encountered an issue with a hoverable drop-down menu that has been functioning smoothly for years. After adding a new sub link, the code broke. Here is the code for the menu: #divMenu, ul, li, li li { margin: 0; padding: 0; } #divMenu { ...

Interactive pop-up window featuring a top section, main content, and bottom section

I have a situation where I've created a modal with sticky headers and footers, and the middle section scrolls based on the content. Everything looks great on Desktop, but when viewed on mobile or tablet devices, the footer is stretched and not fully ...

Utilize React Material UI Slider to dynamically adjust Border Radius in your web design

Utilizing React Material UI's components like the slider and button is essential for this project. The main objective is to dynamically change the border radius of the button using the value obtained from the slider. However, there seems to be a chall ...

Color scheme for navigation bar carousel item background color

I have a navigation bar and carousel within the same section. I want to change the background color of both the navigation bar and carousel item when the carousel indicator becomes active. Any suggestions on how to achieve this using a jQuery function? H ...

Tips on effectively managing sibling nodes with unique behavior on the initial one

Greetings and thank you for taking the time to read and assist. While I have gained a good understanding of how XSLT 1.0 processes XML, there is one issue that continues to baffle me. The problem arises from having a template that matches the first node ...

Improving the Performance of HTML/CSS Animations - Enhanced Animation Speed

I have created an HTML page with CSS animation and transitions. <div class="container-fluid" id="team"> <div class="row first"> <div class="wrapper"></div> </div> <div class="row second"> <div class="wrapper" ...