Balancing columns with active elements to ensure equal resizing

I am working on coding an image that requires specific resizing capabilities:

https://i.sstatic.net/7hLwL.png

The objective is to ensure that when the browser window is resized, the center notch remains proportional and both columns scale uniformly.

Below is the code I have implemented:

.main {
  border: 1px solid #000;
  padding: 22px;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.container {
  max-width: 575px;
  width: 100%;
  height: 100%;
  border-radius: 9px;
}

.container svg {
  display: block;
  width: 100%;
}

/* Right column, the image has is a png with the notches. */
img {
  min-width: 0;
  max-width: 100%;
  height: 100%;
  display: block;
}
<div class="main">
  <div class="container">
    <svg width="575" height="604" viewBox="0 0 575 604" fill="none" xmlns="http://www.w3.org/2000/svg">
          <g clip-path="url(#clip0_1143_882)">
            <g clip-path="url(#clip1_1143_882)">
              <path fill-rule="evenodd" clip-rule="evenodd" d="M9 0C4.02944 0 0 4.02945 0 9.00001V595C0 599.971 4.02944 604 9 604H466C470.971 604 475 599.971 475 595V495C475 490.029 479.029 486 484 486H566C570.971 486 575 481.971 575 477V9C575 4.02944 570.971 0 566 0H9Z" fill="#C4C4C4"/>
            </g>
          </g>
          <defs>
            <clipPath id="clip0_1143_882">
              <rect width="575" height="604" fill="white"/>
            </clipPath>
            <clipPath id="clip1_1143_882">
              <rect width="575" height="604" fill="white"/>
            </clipPath>
          </defs>
        </svg>
  </div>
  <img src="example.png" alt="" />
</div>

I've experimented with CSS masking techniques but without success. As an alternative, I'm considering using the entire section as a background image, although I remain interested in salvaging my original approach.

Below is the svg code for the complete section:

<svg width="1396" height="656" viewBox="0 0 1396 656" fill="none" xmlns="http://www.w3.org/2000/svg">
  <g clip-path="url(#clip0_1143_887)">
    <g clip-path="url(#clip1_1143_887)">
      <path fill-rule="evenodd" clip-rule="evenodd" d="M9 0C4.02944 0 0 4.02945 0 9.00001V595C0 599.971 4.02944 604 9 604H466C470.971 604 475 599.971 475 595V495C475 490.029 479.029 486 484 486H566C570.971 486 575 481.971 575 477V9C575 4.02944 570.971 0 566 0H9Z" fill="#C4C4C4"/>
    </g>
  </g>
  <path fill-rule="evenodd" clip-rule="evenodd" d="M1362 611C1362 606.029 1366.03 602 1371 602H1387C1391.97 602 1396 597.971 1396 593V11C1396 6.02943 1391.97 2 1387 2H605C600.029 2 596 6.02944 596 11V495C596 499.971 591.971 504 587 504H506C501.029 504 497 508.029 497 513V647C497 651.971 501.029 656 506 656H1353C1357.97 656 1362 651.971 1362 647V611Z" fill="#C4C4C4"/>
  <defs>
    <clipPath id="clip0_1143_887">
      <rect width="575" height="604" fill="white"/>
    </clipPath>
    <clipPath id="clip1_1143_887">
      <rect width="575" height="604" fill="white"/>
    </clipPath>
  </defs>
</svg>

Answer №1

It seems like there might be some confusion in your question. If you simply add the style attribute with a value of "width: 100%" to your parent SVG element, it will automatically scale to fit the window while maintaining proportionality.

<svg style="width: 100%" width="1396" height="656" viewBox="0 0 1396 656" fill="none" xmlns="http://www.w3.org/2000/svg">
  <g clip-path="url(#clip0_1143_887)">
    <g clip-path="url(#clip1_1143_887)">
      <path fill-rule="evenodd" clip-rule="evenodd" d="M9 0C4.02944 0 0 4.02945 0 9.00001V595C0 599.971 4.02944 604 9 604H466C470.971 604 475 599.971 475 595V495C475 490.029 479.029 486 484 486H566C570.971 486 575 481.971 575 477V9C575 4.02944 570.971 0 566 0H9Z" fill="#C4C4C4"/>
    </g>
  </g>
  <path fill-rule="evenodd" clip-rule="evenodd" d="M1362 611C1362 606.029 1366.03 602 1371 602H1387C1391.97 602 1396 597.971 1396 593V11C1396 6.02943 1391.97 2 1387 2H605C600.029 2 596 6.02944 596 11V495C596 499.971 591.971 504 587 504H506C501.029 504 497 508.029 497 513V647C497 651.971 501.029 656 506 656H1353C1357.97 656 1362 651.971 1362 647V611Z" fill="#C4C4C4"/>
  <defs>
    <clipPath id="clip0_1143_887">
      <rect width="575" height="604" fill="white"/>
    </clipPath>
    <clipPath id="clip1_1143_887">
      <rect width="575" height="604" fill="white"/>
    </clipPath>
  </defs>
</svg>

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

Choose from the dropdown menu, not from the text

I'm having trouble aligning a select element in Bootstrap without centering the text inside it. Can anyone provide a solution for this issue? I've attempted to center the containing div and then set the text-align property to left for the select ...

Tips for referencing Google Maps initialization in individual files within a website application

After setting up my Google Maps API snippet: <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script> in the index.html file, I encountered the error: Uncaught InvalidValueEr ...

Achieving a layered effect: Bootstrap Navbar on Carousel

Currently, I am designing a mockup and aiming to create a full-screen carousel with the navigation bar links positioned on top of the images. At the moment, the navbar appears transparent until I scroll down the image/slider making it full screen. How can ...

Strange Firefox behavior with absolutely positioned div and percentage height

One of my projects includes a CSS modal dialog that is structured as follows div { position:fixed; top:50%; left:50%; margin:-26% 0 0 -26%; width:46%; height:46%; padding:3%; } Interestingly, this div appears centered in webkit browsers. Ho ...

If the width is divisible by a certain value

I have a question regarding the width of my element that I want to divide by 90. If this width is a multiple of 90, I set the width of the element. If not, I move on to the next. For example, when the window width is 1000px and the element is at full widt ...

The 'download' attribute on HTML elements unexpectedly redirects to a new page instead of initiating a download

Trying to create a download button for an image with the code below: <a href="https://media.npr.org/assets/img/2017/09/14/gettyimages-10141026_slide-67be9fc1bca330b26debade87690b5e84286614d-s800-c85.jpg" class="btn btn-outline-success btn-sm" targe ...

Show image at 100 pixels wide after removing float classes (float-sm-start / float-sm-end) in Bootstrap 5 at a breakpoint

I am in the process of updating my HTML files to Bootstrap version 5.2.3. In the current version (4.6.2), I have been utilizing the float classes left and right to position images with text wrapped around them on their respective sides. Additionally, I ha ...

Struggling to Align Banner in Dynamic Layout

I am currently working on centering the banner image as the resolution size decreases, rather than having it pushed to the right. The specific page I am addressing can be found here. My approach involves utilizing a width of 100%. <!-- BEGIN T ...

Inspecting JavaScript for any attachments

Before hitting the submit button, I need to verify if a file has been uploaded and display a warning message prompting the user to attach a file if it hasn't been done yet. I am looking for guidance on how to achieve this using JavaScript, Prototype, ...

Fluidly move through spaces where subsequent elements align to the top level

In the black container, there is an {overflow:hidden;} CSS property applied The yellow blocks are ordered in code according to the numbers and have {float:left;} I am aiming for the 5th element to align with the element above it: However, currently this ...

Error: when trying to refresh TABLE DATA, an issue occurred with a stale element reference where the element is not connected to the

Apologies in advance for my poor grasp of the English language. I am working on a project where I need to continuously fetch row data from a table using driver.refresh() The first iteration works fine, and the data is retrieved for each row. However, when ...

What is the reasoning behind utilizing the "&" selector in CSS?

.navigation { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: translation: all ease 0.25s; &.expand { transform: translateX(0); } } JavaScript file: $(document).ready(func ...

Fetching JSON data using Javascript/JQuery

My goal is to access JSON data from an online web service that queries a MySQL database for a specific string and use Javascript to present it on an HTML page. My challenge lies in effectively displaying the retrieved information. The relevant part of my ...

Continuous addition of Node structures in a tree

I am attempting to append a node tree to the DOM that has been created using createHTMLDocument. Originally, I approached it like this: (doc represents the node tree) while(doc.head.children.length > 0){ iframewin.document.head.appendChild(doc. ...

Dynamic Isotope grid and seamless inline AJAX commentary

I'm currently utilizing the isotope plugin on my website, which is still in the local development phase. However, I've encountered a CSS issue that I'm hoping to receive assistance with. Here's the scenario: <div class="wrapper"> ...

Adding data to the SharePoint RichText Control using the WinForms WebBrowser Control

I am struggling to modify the content of an SP Rich Text field using the WinForms web browser control. While changing the values of other controls is straightforward, I have encountered difficulties with Rich Text fields. I found some suggestions on this b ...

Ryan Fait's Code for Creating a Responsive Sticky Footer Height

There are quite a few queries regarding Ryan Fait's sticky footer, but I urge you not to dismiss this one immediately! My goal is to have a footer with a dynamically sized height that sticks to the bottom of the page. Ryan Fait suggests wrapping all ...

Arrangement of divs using Bootstrap version 3

Currently working on a project using Bootstrap 3 and aiming to create a layout similar to the one shown in the image provided: Any suggestions on how to achieve this? Any code snippets would be greatly appreciated. Thank you Experimenting with something ...

Tips on adding to Jquery html code while maintaining the current CSS styling

My JavaScript function looks like this: function appendAllQna(qnaList, num){ for (var i in qnaList){ var qnaCom = ""; qnaCom += "<div class='scomment scommentLine'>"; if(qnaList[i].sellerYn == "Y"){ ...

What is the best way to retrieve the initial <ul> element from a JavaScript document?

Just to clarify, I'm looking to target a specific div with a class and the first <ul> from a document (specifically in blogger). Currently, I have a JavaScript function that grabs the first image and generates a thumbnail as shown below: //< ...