Extend the right column in a grid layout to vertically overflow at the same height as the left column using CSS

Is there a simple way to use CSS to ensure that the second column, which will contain a lot of text, overflows vertically at the same size as the left column image tag?

The image changes size based on the window size (responsive) using the Bootstrap grid system.

<div class="row">
    <div class="col-7 col-12-sm">             
        <div style="position:relative" class="col-9">
            <img src="" alt="">
        </div>
    </div>
    <div class="col-5 col-12-sm">
        <div class="mytext">
            Lorem Ipsum is simply dummy text of the printing and
            typesetting industry. Lorem Ipsum has been the industry's standar
            dummy text ever since the 1500s, when an unknown printer took a galley
        </div>
    </div>
</div>

I attempted to add this CSS to my right column:

.mytext {
    overflow-y: scroll;
    height: 500px;
}

However, setting pixels as the height does not work as expected when resizing the browser.

Here is the issue I am currently facing with short size.

This is what happens when I resize down with fixed height.

Is there an easy way to achieve this using CSS?

Answer №1

To ensure your .mytext class has the correct max-height, match it with the height of the image using this code:

.mytext{ max-height:300px; overflow-y:auto; }

You can also set both the image and .mytext to have identical max heights.

Remember to use col-sm-12 instead of col-12-sm for your classnames. When setting column width as col-7 or col-5, it is equivalent to using col-xs-7 or col-xs-5. The new bootstrap version now uses col-n instead of col-xs-n.

For the solution, visit this link: https://codepen.io/freeborn_ig/pen/YzNzGGm

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

Leveraging Jsoup for HTML parsing

As a beginner in coding with Java and using Android Studio, I am currently working on a project involving Jsoup to extract HTML source code from a URL. The main objective now is to parse the HTML for a specific line that contains a link, however, only the ...

Is there a way to attach an event for multiple arithmetic operations to a checkbox?

My form includes 4 checkboxes for different mathematical operations. <form action="" method="POST"> Select number of questions: <input type="number" name="que" value="que"> <br> <br> Select number of series: <select name="sel ...

Relocate the preview division below the button in the Kartik File Input Widget

There are two input file buttons that allow users to upload an image on each button. Upon selecting an image, a preview of the image will be displayed above the button. The current layout is shown here: https://i.sstatic.net/aLAbo.png When images of diff ...

Do not activate hover on the children of parents using triggers

Check out my demonstration here: http://jsfiddle.net/x01heLm2/ I am trying to achieve two goals with this code. Goal number one is to have the mini thumbnail still appear when hovering over the .box element. However, I do not want the hover event to be tr ...

Is there a way to hide an HTML element from view while still allowing it to be found by the browser?

Scenario: A collection of cards with hidden names, but still necessary to search by name Picture album cards without any album names visible, only the images, yet still searchable using Ctrl+F Is there a particular feature or CSS code that would enabl ...

Analyzing comma-separated values file and transforming the information into a modifiable format

Need advice on parsing CSV and using foreach loop.. <?php //output Array ( [0] => Array ( [company] => A Company [address] => A Address [telephone] => A Telephone ) [1] => Array ( ...

What is the best way to align these JavaScripts side by side using div elements?

After searching many sources and attempting various methods, I am still struggling to position two lines of code side by side on my website. My attempted solution can be found at the bottom of the code. http://pastebin.com/mV1DUbg0 The code looked strang ...

Align text within HTML with the use of Bootstrap

Example data value category type item1 100 food fruit item2 50 drinks soda item3 75 snacks chips I want to achieve this forma ...

"Learn how to transfer a selected value from a parent ASP.NET dropdownlist to a textbox in a popup window using JavaScript

I'm struggling to pass the value from a dropdown list in the parent ASPX form to a textbox in the child ASPX form. Parent JavaScript: The first script is used to open the popup window <script type="text/javascript"> var popup; ...

What is the best way to extract words from a string within a textarea using javascript?

Currently, I am focused on improving my skills in JavaScript and HTML. In one of my projects, there is a text area where the user inputs a CSV format like this: 17845 hello bye 789 After input, I get 17845,hello,bye,789. Now, the challenge is t ...

Learn how to efficiently transfer a dynamic subtitle text value from an HTML5 video player to a database

I have successfully developed an HTML5 video player with subtitles. Currently, my goal is to allow the user to submit the subtitle text at a specific timestamp to a database. Despite trying various methods, I am facing challenges in fetching the subtitle t ...

Adding 'invalid-feedback' to 'form-group' in Bootstrap 4 for input validation

Utilizing Bootstrap v4.0.0 for validation on my form group has been working well. For instance, on a change password form, the user is required to input: Old Password New Password New Password (confirm) If the new passwords do not match, the validation ...

Growing background picture

I currently have an iPad serving as a background image. However, I desire for it to be expandable, with the possibility of it being integrated into the header, footer, and the middle section expanding as needed to fill the entire page. I am open to any a ...

Weather Application featuring Circular Slider

I've been on the hunt for a circular slider animation. Imagine it working like this: <input type="range" min="0" max="50" value="0" step="5" onchange="showValue(this.value)" /> <span id="range">0</span> function showValue(newValue ...

How to remove checkbox border using HTML, JavaScript, and CSS

Is it possible to remove the square border from a checkbox in HTML? ...

Issues with Vue-select dropdown functionality are causing inefficiencies

I am utilizing vue-select to generate a standard drop-down menu. However, it comes with a search bar by default that I do not need and prefer to keep it simple. I attempted to hide the search bar by using "display: none" which made it disappear. This is t ...

Vuetify vueJS dialog with elevated design

Is there a way to completely remove the elevation of a v-dialog so that it has no shadow at all? The elevation property in the v-dialog itself and using the class as Class = "elevation-0" have not worked for me. Here is the link to the component ...

What is the most effective method for implementing a background repeated image in Foundation 4 framework?

Currently, I am utilizing the foundation4 framework for my website. In order to achieve a repeating tiled background, I have crafted a custom CSS file and included the following code snippet: body { background: url(img/floorboardsbg.jpg) repeat; } Whi ...

Frames of Animation

Seeking assistance in understanding how to create frame animation using JavaScript or CSS. Attempting to replicate the animation seen on this website. Intrigued by the road animation and unsure if it is achieved using a plugin or just JavaScript and CSS. ...

Retrieve the text content of the paragraph element when its parent is clicked. The paragraph element belongs to a group that contains many

In a function I'm working on, I need to retrieve the specific text within a p element when its parent (.photoBackground) is clicked. The purpose of this operation is to grab the caption for a gallery, where there are multiple p elements with the same ...