Placing 2 elements next to each other - Where the left element remains static and the right element's width increases as the page expands

Hey there! I'm really struggling to position two elements, an aside and a section (I believe the use of these HTML5 elements is important for their content).

On this page Click Here, my goal is to keep the 'Locations' (Aside) element static on the left side of the container div. As for the 'Regions' (Section), I want it to stay on the right side of the page (aligned with the 'Locations' element) and when resized, I need it to remain on the right while decreasing in width, maintaining its current content display. I seem to have set up the inner divs correctly to display when reduced in size, but I can't figure out how to position it next to the 'Locations' element.

Please review the following markup:

<div class="mainwrapper">
  <aside id="locations">
    <h4 style="border-bottom: 1px dotted #990000;">Locations</h4>
    <ul>
      <li>
        <a href="recentwork.htm">
          <span>Recent Work</span>
        </a>
      </li>
      
      ...
      
    </ul>

  </aside>
  
  <section id="regions">
    <h4 style="text-align:left;">Asia</h4>
    
    <div class="thumbcontainer">
      <div class="thumb">
        
        ...
        
      </div>
      
      ...
      
    </div>
  </section>
</div>

And here's the CSS:

.mainwrapper {
  width: 90%;
  margin: 130px auto 0;
  text-align:center;
}

...

.thumb img {
  border:0;
}

You can access the link again Here

Thanks so much for any assistance!

Answer №1

Here's a solution for you...

To address the issue, remove "position: fixed" from the HEADER element, eliminate "width: 90%" from #regions, and update the CSS properties of .mainwrapper as shown below:

.mainwrapper {
    margin: 40px 2% 0;
    padding-left: 168px;
    position: relative;
    text-align: center;
}

Answer №2

To ensure your Locations and Regions elements are aligned properly, consider using float:left for Locations and float:right for Regions. This will place them on the same level as desired.

In addition, utilizing media queries to adjust the width of the Regions element would be beneficial. Instead of a fixed 90% width, consider setting the width conditionally based on screen size using media queries.

For instance, if you need the Regions element to display two photos side by side at 636px wide, create a media query to accommodate this specific width along with margins and padding:

@media (min-width: 956px) { 
#regions {
width: 636px;
}
}

Similarly, for three photos showing at 956px wide, set another media query accordingly:

@media (min-width: 1276px) { 
#regions {
width: 956px;
}
}

By including max-width: 955px, you account for various screen sizes. Using media queries in this manner allows for optimal photo display while maintaining the Locations element visibility.

View an example JSFiddle demonstration here or see it in full screen mode here to observe the responsive design in action when adjusting the browser window width.

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

(no longer supported) We are unsure about the usage of /deep/, >>>, and ::ng-deep, ::v-deep

Since /deep/ has been deprecated, I have found that using global styles instead is the only viable solution. Does anyone know of an alternative solution where we can still maintain encapsulation or scoped styling? ...

What is the best way to specify attributes such as font size and padding for the mobile version in AMP for email?

I attempted to utilize media queries to create a responsive AMP email, but it seems that this feature is not supported in AMP. However, I discovered that you can define media="(max-width: 599px)" and media="(min-width: 600px)" for </amp-img>, but the ...

Queueing up file downloads through a web browser

When trying to download multiple files from a server, I am required to queue them up instead of downloading in parallel. Unfortunately, I do not have access to the download server, so my only option is to work with the browser. Is there an API available t ...

offspring of offspring in jquery animation remains stationary

I'm experiencing an issue with a jquery animation on containers that are set to 100% width and height. Specifically, the children elements that have position absolute move with the container, but when a child of a child has two instances of position a ...

What is the best way to assign the order position in CSS?

I recently attempted to incorporate a CSS animated background into my project. Here is how it currently looks: The particle effect hovers above the menu list (which currently just says "test"). The CSS code for my particles is as follows: .circles { pos ...

The text-decoration is here to stay

Currently, I am facing an issue with the customization of a wordpress theme related to the styling of links within posts. Although I have tried to change the color and remove underlining using CSS rules, I am unsuccessful so far: a, .entry-meta a, entry-c ...

Analyzing text with improperly defined attributes

As I attempted to analyze an HTML document as XML by adding the XML start at the beginning, I encountered an issue with attributes within tags. <tr> <td class="yfnc_tabledata1" nowrap align="right">Jun 4, 2013</td> <td class="yfnc_tab ...

Moving specified data from one interactive table to another interactive table

In my setup, there are two tables - one for products and another for customers: <table cellpadding="0" cellspacing="0"> <thead> <tr> <th>Product Code</th> </tr> </thead> ...

Creating a Dynamic Navigation Bar with HTML and CSS

I've been exploring the code on w3schools.com, and while there are some great examples, I'm struggling to understand it all. Unfortunately, there aren't any instructions on customizing the code for a third level of menus. Can someone simplif ...

What is the best way to utilize a single component for validating two other components?

I am encountering an issue with my components setup. I have three components in total: GalleryAddComponent, which is used to add a new element, GalleryItemComponent, used to edit an element, and FieldsComponent, the form component utilized by both GalleryA ...

Is there a way to locate ComputedStyle elements using Nokogiri?

I am currently using Ruby along with Nokogiri to parse through HTML documents. I am looking to select all nodes that match a CSS class with the style attribute display: none, but the CSS class is unknown in advance. For example: <html> <body&g ...

Retrieving the value of a radio button using jQuery and Ajax

Looking for assistance with radio buttons... <input type="radio" id="flip" name="flip" value="Head" checked="checked" /> Head <input type="radio" id="flip" name="flip" value="Tail" /> Tail I'm attempting to process a form with ajax, try ...

Why Does my Overlay Keep Bouncing when Using JQuery to slideDown / slideUp Text on Image?

Can anyone help me replicate the text overlay effect that is seen when hovering over an image on The Guardian website? I have almost got it working, but whenever my mouse moves over the trail-text area, it starts bouncing (slideDown slideUp) repeatedly. I ...

Flex just can't seem to align correctly

I'm having trouble getting this to work properly. I am using React and styled components, but the justify/content alignment is not functioning as expected. The setup includes a div with flex properties, where the flex direction is set to column. With ...

Set the HTML content as a string in the Html variable, similar to innerHTML but without using JavaScript directly from an external

When working in an embedded ruby (html.erb) file, I encounter a situation where I have a string of HTML such as variable_string = "<p>Some <strong>Content</strong></p>". In JavaScript, we can easily update the DOM with Element.inn ...

The jQuery scrollLeft function seems to be stuck and not working correctly

I have a container div with a ul inside of it set up like this CodePen: http://codepen.io/example/123 Why won't the scroll feature work? HTML: <div id="container"> <ul class="list"> <li>apple</li> <li>orange& ...

arranging elements within a container

<td id="name_3869-0_0" style="position: relative; " colspan="4"> <div style="float:left;width:100%"> <img src="/img/1.gif" align="middle" style="margin-right: 10px;" class="company_symbol" border="0"> <strong style= ...

What is the correct way to retrieve a JSON object instead of getting [Object object]?

Creating a basic web scraper integrated with mongoDB. Even though the API returns the JSON object in the correct format, when trying to append it to a bootstrap card on the page, I'm getting [Object object]. Below is my JavaScript code running on th ...

Creating flexbox items with equal height

I have a flexbox parent with flex-direction set to row. Within this parent, I have two children that I want to have the same height! Both of these children contain dynamic content with varying heights. The issue I'm facing is that when I add text t ...

Using Javascript and JQuery to create an alert that pops up upon loading the page is not effective

I am having trouble making an alert show up when my website loads. The Javascript code is functional when directly included in the HTML, but once I move it to a separate file named script.js and link it, nothing happens. Can someone please help me identify ...