Designing an image to adjust to different screen sizes while maintaining its specified dimensions

I'm currently retrieving pictures from Bing, but unfortunately you have to specify the height/width of the image in the URL. I want the map image to always be aligned with the table on the left, regardless of the desktop screen size or the number of rows added to the table. The width should always fill the entire col-7 container.

I've tried using height:auto, width:100%, and vice versa, but it doesn't work on every device.

It may seem like a basic question, but I've been stuck on it for a few hours and would appreciate any input.

<!-- CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />

<div class="information" style="background-color:gray;">
    <div class="container-fluid no-pad-mar pt-4 pb-4">
        <div class="row no-gutters">
            <div class="col-md-5 col-12 text-center">
                <div class="card">
                    <div class="card-body">
                        <h2 class="mb-4">Information about yxhrferfefe</h2>
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td>Population</td>
                                    <td>127,942</td>
                                </tr>
                                <tr>
                                    <td>Country</td>
                                    <td>United States</td>
                                </tr>
                                <tr>
                                    <td>TimeZone</td>
                                    <td>America/Los_Angeles</td>
                                </tr>
                                <tr>
                                    <td>Flag</td>
                                    <td>Latitude</td>
                                    <td>34.17056</td>
                                </tr>
                                <tr>
                                    <td>Latitude</td>
                                    <td>34.17056</td>
                                </tr>
                                <tr>
                                    <td>Longitude</td>
                                    <td>-118.8367</td>
                                </tr>
                                <tr>
                                    <td>UTC Offset</td>
                                    <td>-08:00:00</td>
                                </tr>
                                <tr>
                                    <td>daylight</td>
                                    <td>True</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-md-7 col-12 text-center">
                <img src="https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/34.17056,-118.8367/11?ms=950,700&od=1&c=en-GB" width="100%" height="100%">
            </div>
        </div>
    </div>
</div>

Answer №1

This solution works perfectly by applying the background-image property to ensure it functions correctly on all viewports. If you use this as an image, it may not display properly on smaller devices.

https://jsfiddle.net/Sampath_Madhuranga/mLto98bn/11/

.map {
      background: url('https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/34.17056,-118.8367/11?ms=950,700&od=1&c=en-GB&key=AijbFhynMi9YlUoC5sbBKfrfbnkcMJ34sYBEORQwbsviodnw8nTkkgh5se5COtMs') ;
      background-repeat:no-repeat;
      background-size:cover;
}

@media only screen and (max-width: 768px) {
  .map {
    min-height: 510px !important;
  }
}
<!-- CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
    
    
 <div class="information" style="background-color:gray;">
<div class="container-fluid no-pad-mar pt-4 pb-4">
<div class="row no-gutters">
<div class="col-md-5 col-12 text-center">
<div class="card">
<div class="card-body">
<h2 class="mb-4">Information about yxhrferfefe</h2>
<table class="table">
<tbody>
<tr>
<td>Population</td>
<td>127,942</td>
</tr>
<tr>
<td>Country</td>
<td>United States</td>
</tr>
<tr>
<td>TimeZone</td>
<td>America/Los_Angeles</td>
</tr>
<tr>
<td>Flag</td>
<td>Latitude</td>
<td>34.17056</td>
</tr>
<tr>
<td>Latitude</td>
<td>34.17056</td>
</tr>
<tr>
<td>Longitude</td>
<td>-118.8367</td>
</tr>
<tr>
<td>UTC Offset</td>
<td>-08:00:00</td>
</tr>
<tr>
<td>daylight</td>
<td>True</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-7 col-12 text-center map">
<!-- <img src="https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/34.17056,-118.8367/11?ms=950,700&od=1&c=en-GB&key=AijbFhynMi9YlUoC5sbBKfrfbnkcMJ34sYBEORQwbsviodnw8nTkkgh5se5COtMs" width="100%" height="auto"> -->
</div>
</div>
</div>
</div>

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

Showing Information in an HTML Table

I am new to the world of PHP programming and constantly searching for solutions to my problems. If anyone has any ideas, please share them - I greatly appreciate any help in solving this issue. Within my database table, I have data structured as follows: ...

Using Angular to scroll within a <div> that is obstructed by other <div>s and concealed by

I am currently in the process of developing a website using Angular. I have implemented a card feature that allows for text selection from a menu on the left side. The texts are displayed using the *ngIf directive. However, I encountered an issue where if ...

How to align the "bootstrap navbar li items" in the center across all page widths

I'm trying to center the li items "on the entire page width" in this basic bootstrap navbar that I've shared. I attempted using "justify-content-center" in the parent. It did center the navbar items, but not across the entire page width. The ite ...

The offcanvas menu in the NextJS Tailwind website does not handle hover or tap events properly when outside of the parent dimensions

My header includes an off-canvas menu that slides in from the right side. Everything seems to be working fine, except for one issue: when the menu is open and visible, the mouse and touch events pass through it to the content underneath. Check out the cod ...

Attempting to apply the 'Tw Cen MT Condensed Extra Bold' typeface using CSS styling

I'm having trouble getting the 'Tw Cen MT Condensed Extra Bold' font to work in my website header. Even when I try to style it with bold, it just doesn't look right. I created the banner in Photoshop and now I want to recreate the text ...

Guide on including a JavaScript file in HTML during execution on Node.js

I have developed a basic nodeJs server with the following code in my server.js file: var http = require('http'); var fs = require('fs'); var path = require('path'); var server = http.createServer(function(req, resp){ // P ...

Is there a way to use regular expressions to search for class names within nested div elements?

I'm struggling to find nested divs like these in my document object model (DOM) <div class="two-columns some-other-class"> <div class="two-columns some-other-class"> </div> </div> I attempted to search for neste ...

Discovering more about this topic

Looking for a way to create an expandable box that enlarges when "read more" is clicked, revealing text below it. And also looking to add a button that closes the expanded text back up. Experimented with the toggletext JavaScript command, as found on this ...

How come Bootstrap Select isn't displaying the selected value when I provide a default option?

Why is it that an object with a set value is only displayed initially if the "--Select--" parameter is omitted? Do you have any insights into this behavior? @Html.DropDownListFor(m => m.FlightDetails.AirlineId, ViewBag.AirlineList as SelectList, "--Se ...

Tips for adjusting the size of an image in both the vertical and horizontal axes using CSS

As a beginner in HTML, I am currently facing an issue while trying to display a set of pictures. My goal is to resize the pictures based on the current window size while maintaining the aspect ratio. Despite experimenting with various methods like using wi ...

Divs sliding out of alignment

I am experiencing an issue with the scrolling behavior of a wrapper div that contains two nested divs. Specifically, when I scroll the wrapper horizontally on Android devices, the header section and content section seem to be out of sync and there is a not ...

jQuery navigation is experiencing issues due to conflicting buttons

I am currently developing a web application that features two buttons in the header: Share and Options. When a button is clicked, its related content expands and collapses when clicked again. The issue arises when the user clicks on the share button and th ...

Ways to confirm the validation of radio buttons in a form and implement CSS

I am having trouble adding validation to a form with radio buttons displayed as labels. I want to show a red border around the radios/labels or outer div when a radio button hasn't been checked before the user submits the form. I have attempted this ...

Align two lines of text in the center of a table

I need assistance with creating a table in HTML for an email. I would like to display a two-lined text, where the top line is formatted in bold. <table style="width:100%"><tr > <td style="background-color:#000000;color:#fff;font-fam ...

Standard Tooltip appears when Tooltip is activated

$(function () { $('[data-toggle="tooltip"]').tooltip() }) <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></scri ...

Creating a WordPress widget that links to a local file

Hey there, I've been attempting to utilize the text widget in order to link to a local file, but unfortunately, it's not working as expected, and I'm unsure of the reason why: Here is what I am using: <a href="file:///D:/" target="_blan ...

What could be causing the error message 'Alias configuration for Field browser is not valid' to appear when attempting to compile SCSS using Webpack through the terminal?

Recently, I decided to try using webpack to compile my scss files for the first time. However, when attempting to start it, I encountered an error message stating: Field 'browser' doesn't contain a valid alias configuration In addition, ano ...

Modify visibility or enable state of a text box according to a checkbox in PHP

Currently, I am utilizing PHP to exhibit a vertical list of numbered checkboxes, with one checkbox for each day in a specific month. Next to every checkbox, there is a text box where users can input optional notes for the selected day. To ensure that users ...

Ways to align content in the middle of a Row component

Can someone help me figure out how to center some cards inside a row element? <Row className="d-flex justify-content-center"> {cardData.map((data) => { return ( <Col> < ...

Grails Error: Cannot find method signature for org.apache.catalina.core.ApplicationHttpRequest.getFile()

Every time I try to access the upload page of my Grails application, I encounter this error message: No signature of method: org.apache.catalina.core.ApplicationHttpRequest.getFile() is applicable for argument types: (java.lang.String) values: [file] ...