Maintain an equal distance between 2 out of 3 elements while resizing the window to ensure responsiveness

There are two image divs stacked on top of each other, positioned beside a fluid header logo (.svg) also contained in a div.

The HTML:

<header class="site-header" role="banner" itemscope="itemscope" itemtype="http://schema.org/WPHeader"><div class="wrap"><div id="menu_container"><img src="http://95.85.63.245/wp-content/uploads/dynamik-gen/theme/images/Hamburger_optimized.svg" alt="menu"  class="menu-btn" /><div class="menu_spacer"></div><img src="http://95.85.63.245/wp-content/uploads/dynamik-gen/theme/images/searchicon.png" alt="zoek"  class="search_icon" /></div>


<div class="title-area"><h1 class="site-title" itemprop="headline"><a href="http://95.85.63.245/"></a></h1></div><div class="vr_menu_logo"><a href="/"><img src="http://95.85.63.245/wp-content/uploads/dynamik-gen/theme/images/logo_VR_font.svg"></a></div>
</div></header>

The CSS:

.vr_menu_logo{
  max-width:95%; 
  float:left;
  margin-right:20px;
}

#menu_container {
  max-width: 5%;
  float: right;
}

.menu-btn{
 cursor: pointer;
 max-height: 30px;
 max-width: 30px;
 margin-top:2em;
}

.menu_spacer{height:4em;}

.search_icon{
  cursor: pointer;
  max-height: 24px;
  max-width: 24px;
}


.site-header .wrap {
  width: 1260px;
}
.site-header .wrap {
  margin: 0 auto;
  padding: 0;
  float: none;
  overflow: hidden;
}

Objective: When resizing the browser window, the small hamburger and search icons should remain aligned with the top and bottom of the logo respectively. All three separate items should function as one cohesive logo.

View the cssdesk example here:

I have tried using a spacer div with a maximum height or display:table-cell; but I can't seem to make it work. Does anyone have any suggestions? (Using JavaScript is an option as well, but ideally, this could be achieved with CSS...)

Answer №1

Here is a demonstration showcasing the utilization of flexbox. It's worth noting in the code snippet that there are two div elements which are identical except for their differing height values. This visual example may assist you in achieving your desired layout design. Be sure to verify the browser compatibility required, as flexbox is considered a relatively modern technology.

http://jsfiddle.net/zn50mmnu/

HTML:

<div class="flexy f1">
    <span class="menu">M</span>
    <span class="search">S</span>
</div>
<div class="flexy f2">
    <span class="menu">M</span>
    <span class="search">S</span>
</div>

CSS:

.flexy {
    float: right;
    clear: both;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 2px solid red;
    margin: 10px;
}

.f1 {
    height: 50px;
}

.f2 {
    height: 90px;
}

.menu {
    background: red;
    width: 1em;
}

.search {
    background: blue;
    width: 1em;
}

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

When imported, Node / JS instantly generates a new instance

Is there a way to instantiate a class without importing it first and using new afterward? Instead of var mainClass = require('../dist/main'); // has "class Main { ... }" var mainInstance = new mainClass(); I am looking for something like var ...

Changing the default yarn registry for a specific project

Typically, I fetch packages from the internal server by using the command: yarn config set registry http://custom-packages-server.com However, for a new project, I want to switch back to the default registry without affecting other projects. If I try cha ...

How does the PhoneGap API handle Timestamp format?

Within the realm of app development, phoneGap offers two vital APIs: Geo-location and Accelerometer. Both these APIs provide a timestamp in their onSuccess method. In Accelerometer, the timestamp appears as '1386115200', whereas in Geo-location i ...

Creating secure RSA keys using a predetermined seed - a step-by-step guide

Is it possible to utilize a unique set of words as a seed in order to recover a lost private key, similar to how cryptocurrency wallets function? This method can be particularly beneficial for end-to-end encryption among clients, where keys are generated o ...

Creating Typescript types based on the values of other props: A guide

Can the TypeScript prop type be dynamically changed based on the runtime value of another prop? For instance type MyComponent = { propA: boolean | string propB: typeof propA boolean ? number : string } Is it feasible to determine the prop type of p ...

Generate dynamic maps that are exportable to HTML format

I've utilized Leaflet to produce engaging interactive maps in R. However, I'm encountering an issue when trying to export the maps - the background map appears grey after exporting. library(leaflet) library(htmlwidgets) m <- leaflet(data.fra ...

Retrieve the child element index of a specific element using jQuery

I am dealing with a group of 'DIV' elements, each containing a list of 'p' elements. Take a look at the example below: <div class="container"> <p>This is content 1</p> <p>This is content 2</p> ...

Confirming the presence of an image using jQuery without enforcing it as mandatory

Situation: In my setup, I maintain a database that holds details about various items. Currently, I utilize a dynamic form to retrieve and exhibit the existing information on any item stored in the database. Any modifications made on the form are promptly ...

Converting a class with two lists into an MVC 4 controller with Ajax functionality

Recently, I attempted to send a class with two lists via ajax to an MVC controller. Here is the code for the MVC Controller: [HttpPost] public JsonResult AfficherDetailsFacture(AfficheDetails afficheDetailsFacture) { // do some stuff } Below is the ...

How to Align HTML Menu in the Middle of the Page

I've been struggling to center my menu on the page. I tried setting the display to block and using margin auto for left and right, but it's not working as expected. You can see the issue in this JSFiddle. Any help would be appreciated. <ul id ...

Using AngularJs to have two ui-views on a single page

As a beginner in AngularJs, I encountered an issue with having two ui-views on the same page. When I click a button to show the view for goals, both the form for goals appear in ui-view 1 and ui-view 2 simultaneously. I have been working with states but I ...

Maintaining Styles After Focus is Removed in CSS: A Guide

The CSS that styles our buttons is as follows: .btn-outline-primary { color: blue; border: 1px solid blue; background: transparent; transition: all 0.3s ease 0s; } .btn-outline-primary:hover, .btn-outline-primary:focus { background: ...

Error: Unable to assign values to undefined properties (specifically 'styles') when using withLess, withSass, or withCSS in next.config.js within Next.js

I have been attempting to set up a NextJS 12 project with custom Ant Design. Following some examples I found, it seems I need to configure my next.config.js file with the libraries @zeit/next-sass, @zeit/next-less, and @zeit/next-css. However, when I try t ...

Inject the error into the Router in Express.js, utilizing Node.js

Is it possible to pass an error into an express.js Router? The express.js documentation does not provide a clear answer regarding passing errors in relation to middleware, routers, and error handling (I am unable to include links as I lack reputation). I ...

Ways to activate the enter key

Here we have the input bar and search button setup in our HTML code: <div> <div class="input-group search-bar"> <input type="text" class="form-control search-box" placeholder="Search people" autofocus="" ng-model="searchPeople"& ...

Tips for Importing HTML Table Data Line by Line into SQL Table

I have the following code here. I am looking to insert HTML table data row by row into an SQL database. However, with this current code, only the last row is being stored in the database table. I believe I need to implement a loop to read the data from e ...

Node JS failing to fulfill promises before returning

Seeking some assistance here. I have a series of promise-returning functions structured with .then() that ultimately formats data for the client. However, it seems that the server is sending the 'ff' variable to the client before the formatting f ...

What is the best way to determine if any of the list items (li's) have been marked as selected?

<div id='identifier'> <ul id='list'> <li id='1' class="">a</li> <li id='2' class="">a</li> <li id='3' class="">a</li> <li id='4' class=" ...

Modifying SASS variable values based on the presence of specific text in the page URL

How can I utilize the same SASS file for two different websites with similar functionality but different color schemes? My goal is to dynamically change the color based on the URL of the page. However, I am facing challenges in extracting the page URL from ...

Experience the dynamic expansion of a droppable div as you elegantly drop an element within

When the questions "question1" and "question2" are dragged into "questionslots," I want the "questionSlots" div to expand its size dynamically when the second question is dropped into it. This means that both questions should be accommodated and visible wi ...