Create three div elements that mimic the appearance and functionality of a video to the fullest extent possible

Dear all, I am currently working on a project where I aim to achieve a layout similar to the one featured in this video. The goal is to have 3 divs aligned horizontally, with an image div positioned at the center while the other two divs contain random letters. Additionally, I need the image to maintain its aspect ratio when resizing. Is it possible to implement such flexibility using JavaScript?

Here is my current progress:

<div class="container">
  <div class="text-block text-block-one">
    <div class="text-wrapper">
      <h1>Hello there</h1>
      <h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat  </h3>
    </div>
  </div>
  <div class="image-block">
    <div class="image-container">
      <img src="https://via.placeholder.com/450x750">
    </div>
  </div>
  <div class="text-block text-block-two">
    <div class="text-wrapper">
      <h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat </h3>
    </div>
  </div>
</div>

Snippet of my SCSS files:

body, html {
  margin: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: #efefef;
}
h1,h2,h3 {
  margin: 0;
}
h1 {
  margin-bottom: 20px;
}
img{
  max-width:100%;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
* {
  box-sizing: border-box;
}



.container {
  display: flex;
  position: relative;

  width: 100%;
  margin: 0px auto;
  
  
  .text-block {
    width: 37.645448%;
    background: #e3e3e3;
    padding-top: 250px;
    
    .text-wrapper {
      margin: 0 10%;
      overflow: auto;
    }
    
  }
  
  .image-block {

    .image-container {
      
    }
  }
  
}




Answer №1

Here is some CSS that you can try:

.container {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: row;
}
.image-block{
    width: 33%;
    height: auto;
}
img{
    height: 100%;
    width: 100%;
}
.text-block {
    width: 33%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin: 0 auto;
}
.text-wrapper {
    width: 100%;
    height: auto;
}

h3 {
    margin: 0 25px;
}

This CSS works well for handling videos too.

Answer №2

Your CSS code was originally written in SASS, but I have converted it to regular CSS structure and set a maximum width of 450px for the image container. Here is the revised code that should give you the desired result:

body, html {
  margin: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: #efefef;
}
h1,h2,h3 {
  margin: 0;
}
h1 {
  margin-bottom: 20px;
}
img{
  max-width:100%;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
* {
  box-sizing: border-box;
}  
   
.container {
  display: flex;
  position: relative;
  width: 100%;
  margin: 0px auto;
}      
.text-block {
    width: 37.645448%;
    background: #e3e3e3;
    padding-top: 250px;        
}
.text-wrapper {
    margin: 0 10%;
    overflow: auto;
}
.image-container {
  max-width: 450px;    
}

You can view the updated version here: https://jsfiddle.net/ypt1vfs3/

I hope this aligns better with your intentions.

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

Set up the configuration for express to access an external API through proxy.conf.json while in production mode

I am currently managing two applications on Heroku, one being myserverapi (built with Spring Boot) and the other being a client-side Angular app named client. The server is hosted at myserver.heroku.com while the client resides at myclient.heroku.com. At t ...

After the execution of the script by V8, which phase will be initiated first?

Scenario // test.js setTimeout(() => console.log('hello'), 0) setImmediate(() => console.log('world')) Simply execute node test.js using node v12.12.12 on an Intel MacBook Pro. The output may vary: hello world Sometimes it is: ...

Form a column containing both row object data and html code elements

I am in the process of creating a unique column within my table, allowing me to execute specific actions and generating HTML code based on the object defining the row. Being new to Angular, I believe I should utilize $compile, but I am unsure of how to pr ...

The result of calling addEventListener is undefined

My issue lies with the addEventListener function, as it is not working correctly. I've created a function that requires an event listener to track scrolling and then execute a callback function. window.addEventListener("scroll", checkPosition); Unf ...

What is the reason behind using AJAX to attempt sending a new URL request on

Having a strange issue with my product list. When trying to edit a product by clicking on it, I am redirected to the product form where an AJAX request is supposed to be sent to getFiltersGroup. However, on error, the AJAX request is somehow being sent to ...

What is the best way to reset the 'aria-expanded' attribute to 'false' as I navigate to the following element?

My menu has 2 dropdown buttons, each with a default 'aria-expanded'=false value. The buttons also have the 'up' and 'down' classes to indicate when they are expanded or closed. The issue arises when I click on the first button ...

Easy Steps to Simplify Your Code for Variable Management

I currently have 6 tabs, each with their own object. Data is being received from the server and filtered based on the tab name. var a = {} // First Tab Object var b = {} // Second Tab Object var c = {} // Third Tab Object var d = {}// Fou ...

Highlighting Navbar Items

Can anyone provide advice on how to highlight a navbar item when clicked? I'm unsure if I should use Angular or CSS for this. Any guidance would be greatly appreciated. <div class="collapse navbar-collapse" id="navbarNav"> <ul class ...

If viewed on a mobile device, separate the array (indexed list) into two rows

Currently, I am working on my Ionic project where I am trying to implement an indexed list horizontally instead of vertically. While the list looks good as it is now, I want to make sure it supports smaller screen devices too by splitting the list into two ...

Creating an animated diagonal line using TweenMax/EaselJS can add a dynamic element to your designs

I am looking to create a constellation by connecting stars with animated lines. I have attached an image to show the desired end result. The stars and lines are generated using HTML5 canvas and easelJS. Below is the code snippet I have been working on, wh ...

Stop the stutter in Chrome caused by scrolling animations

I'm encountering a delay with the scroll.Top() function. This issue is specific to Google Chrome on Desktop. Here is the jQuery code I am using: $('html, body').animate({ scrollTop: $('#second').offset().top-140 }, 'slow&apos ...

Resetting clears the date default value

When the page is loaded, the date input field is automatically set to the current date. However, if the form is reset, instead of restoring the default date, the date field is cleared, as shown in the images below: Page load Form reset // app.component. ...

Exploring the React Hook lifecycle methods of componentWillReceiveProps and componentDidUpdate

I am facing two main challenges: Despite the React guideline discouraging the use of derived state, there are still certain edge cases where it is necessary. In the context of a functional component with React Hook, what would be the equivalent implemen ...

Transferring data from a PHP array to a JavaScript array

Trying to transfer values from a PHP array to a JavaScript array and facing an issue. Here's what I'm doing: $k_data = json_encode($k) This results in k_data = [2,3,4,8,9] In JavaScript, my code looks like this: var s4 = [[]]; for(var i = ...

Executing JavaScript Code Through Links Created Dynamically

I am currently developing a website with a blog-style layout that retrieves information from a database to generate each post dynamically. After all posts are created, the header of each post will trigger an overlaid div displaying the full article for tha ...

The maximum size for MongoDB documents is restricted to 16 megabytes

When referring to Document, is it talking about the complete document collection or the individual documents within the collection? A similar question was posed on Stack Overflow: Mongodb collection maximum size limit? However, I am having trouble graspi ...

Unable to retrieve the value from Textarea component

Below is the HTML code I have written: <textarea class="form-control ckeditor" name="home_b1" id="home_b1"> <article style="width: 55%;"> <h2 style="text-align:center"> <span style="color:#82b04e;font-size:24px"> ...

Error: The callback specified is not a valid function

Here is a function example: reportAdminActions.reportMemberList(project, function(data) { console.log(data); }); This particular function gets called by another ajax operation, similar to the one shown below: reportMemberList: function(projectId, ca ...

Refresh the Google Maps location using GPS coordinates

Currently, I am working with an Arduino that has a GPS chip and processing NMEA strings with Python. I have an HTML file set to auto-refresh every x seconds to update the marker's position. However, I would like to update the position information with ...

Safari displays an inexplicable gray border surrounding the <img/> element, despite the actual presence of the image

https://i.stack.imgur.com/4QR52.png There is an unexpected gray border visible around the dropdown image, as seen above. This occurrence has perplexed me because, according to several other queries, this problem arises when the image's src cannot be ...