image in responsive css design

Image 1 (Current Layout)

Image 2 (Desired Layout)

I am trying to achieve a responsive layout similar to the second image. However, I seem to be stuck with the layout from the first image.

Here is the CSS code I'm currently using:

@media (max-width: 960px) {
    .nav {
        width: 100%;
        height: 2em;
    }

    #nav-icon {
        width: 100px;
        height: 50px;
    }

    .container {
        width: 100%;
        margin: 0;
        padding: 3%;
    }

    .container div {
        display: inline;
        width: 45%;
        margin: 0;
        padding: 1%;
    }

    .container div img {
        width: 100%;
    }
}

If anyone could offer assistance on how to achieve the desired layout, it would be greatly appreciated! Thank you!

Answer №1

To achieve a responsive design, I recommend utilizing Bootstrap's grid layout found at Bootstrap. You can easily create a grid by using the classes

col-xs-6 col-sm-6 col-md-6 col-lg-6
. In the first column, insert an image with full height. Then in the second column, add two images vertically aligned using CSS properties.

Answer №2

Utilize the Bootstrap grid system to create responsive images effortlessly.

Below is the code for your image. If there are any alignment issues based on screen width, you can address them using the @media rule.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
 <div class="row">
    <div class="col-xs-12" style="display:absolute;">
       <div class="col-xs-6">
           <img class="img-responsive" src="http://i.imgur.com/neOKPvD.png">
       </div>
       <div class="col-xs-6">
           <div class="col-xs-12">
           <img class="img-responsive" src="http://i.imgur.com/fYeBJ8S.png">
            <h4>Add text here</h4>
            <p>description</p>
           </div>
           <div class="col-xs-12">
           <img class="img-responsive" src="http://i.imgur.com/Y6wIPnl.png">
           </div>
       </div>
    </div> 
 </div>
</div>

</body>
</html>

Answer №3

<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>

<h1>Displaying in Full Page </h1>

<div class="w3-row w3-col s9 ">

<div class="w3-container w3-half ">
  <img src="http://i.imgur.com/OKzIMYS.png">
</div>

<div class="w3-container w3-rest ">
  <img src="http://i.imgur.com/HcNSP13.png">  
<p class="w3-large" <strong> Animated Vector</strong> </p>
<p class="w3-text-grey w3-opacity w3-large"><i>Art, Design, Web </i></p>
<br>
<img src="http://i.imgur.com/DiqFrE1.png">
</div>
</div>

</body>
</html>

Answer №4

Gratitude to everyone~~~ I believe I have discovered how to accomplish that task. I utilized the css3 property: column. (css3 column property) It seems quite similar to the bootstrap grid layout. This is my first time asking a question here, and I received numerous helpful responses in such a brief period. You all are amazing! Thank you once more!

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

Vanish and reappear: Javascript block that disappears when clicked and shows up somewhere else

My goal is to make three squares randomly disappear when clicked on the page. However, I am facing an issue where some of them, usually the 2nd or 3rd one, reappear elsewhere on the page after being clicked. I have created a jsfiddle to demonstrate this: ...

Tips for avoiding accidentally selecting nearby text while holding down a button on your mobile device

My application requires the user to press and hold a button to record audio. However, on mobile devices, when the user holds the button, the browser attempts to select nearby text due to finger pressure. While this behavior is understandable, I want to pre ...

Why is there a mismatch between CSS and Angular 6 selector components?

website.html <website-chat></website-chat> chat-page.html <h1>Greetings</h1> chat-script.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'website-chat', templateUrl: '. ...

Tips for dynamically retrieving a CSS file for an HTML page

With multiple html pages containing the same navbar, I made the decision to place the navbar in its own file called navbar.html and use ajax with jquery.get() to dynamically load it onto each page. This prevents redundant code across all pages. Currently, ...

Can we dynamically adjust font size based on the width of a div using CSS?

My div is set to 70% width and I have a specific goal in mind: To fill that div with text To adjust the font size so that it takes up the entire width of the div https://i.stack.imgur.com/goVuj.png Would it be possible to achieve this using only CSS? B ...

Using HTML to load an image is not possible, as it can only be done using CSS

I am currently dealing with a CSS issue in my project. Here is the code snippet from my stylesheet: .Img{ background: url('../assets/Trump.png'); } Now, let's take a look at the corresponding HTML code: <div class="Img"> However, ...

Having trouble getting the styles property to work in the component metadata in Angular 2?

Exploring Angular 2 and working on a demo app where I'm trying to apply the styles property within the component metadata to customize all labels in contact.component.html. I attempted to implement styles: ['label { font-weight: bold;color:red } ...

Removing all HTML elements within the div container

My HTML code includes the following: <div class="row" id="conditional-one"> <div class="large-12 columns"> <h3><?php echo $arrayStage_rule_one_title?></h3> <p> <?php echo $arrayS ...

Ways to deactivate the submit button using Cookies, sessions, or local storage

Although cookies and storage can be deleted, they can still help prevent many human spammers who are unaware of this. How can I temporarily disable the form submit button on a specific page for just one day? I want to create a code that saves "Submitted" ...

JavaScript Function Not Executed in Bottom Section

I've implemented AngularJS includes in my project. Below is the code snippet from my index.html: <!DOCTYPE html> <html ng-app=""> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> ...

Tips for positioning a Material UI Button and TextField side by side, perfectly aligned on the same line and height

I am currently working on aligning a <Button> from the Material UI library so that it is positioned at the same height as the <TextField> next to it and perfectly aligned with that field. Both the <Button> and the <TextField> are e ...

What could be causing my "onChange" function to not work as expected?

export function UpdateData(props){ return( <div> <div className='updateForm'> <form> <div className="form-group"> <label>Your ID:& ...

Show the checked options retrieved from controller

I am facing an issue with displaying certain checkbox values from the controller. In order to properly save these values, I believe it would be best to declare them in the controller and then use them in the HTML. However, my current code is not successful ...

Navigating jQuery Tabs by Linking to a Specific Tab in a Separate File

I am currently using Bootstrap 3 to develop a basic website. On the about.html page, I have set up Tabs with various content. <ul class="nav nav-tabs" id="TabSomos"> <li class="active"><a href="#somos" data-toggle="tab">About Us</a> ...

What is the best way to activate an onchange function when using a <select> element?

Is there a way to automatically trigger a JavaScript function without the need for user input, while still having a default option selected? <select class="custom-select" name="" id="timer1numbers" onchange="getSelecte ...

Ways to center text in a div using vertical alignment

/* Styles for alignment */ .floatsidebar { height: 100%; float: left; overflow: hidden; width: 30px; line-height: 1.5; } .vertical-text { height: 100%; display: inline-block; white-space: nowrap; transform: translate(0, 100%) rotate(-90 ...

Switch button while moving cursor

I'm struggling with getting this 2048x512 image, which has 4 stages of transition, to work properly. While I know how to switch it to the final stage on hover, I can't seem to figure out how to incorporate a transition effect. Can someone help? ...

After deploying DRF, the CSS in Django admin is not displaying

After developing a web application using Django Rest Framework and React, I faced an issue during deployment on IIS. While the deployment is successful, I encountered a problem with the Django Admin where the styles were not displaying properly. This led t ...

I am encountering issues with setting a background image in Bootstrap 3.1.1 while trying to achieve a par

I'm struggling to add a background image to my bootstrap site. I'm attempting to create a parallax site using stellar.js, and while the site is functional with text on each slide and correct scrolling links, the images just won't load. Despi ...

Unique design Radio Button Inputs with Custom CSS Styling and Enhanced Accessibility for Voice Controls

On my website, I have implemented custom radio buttons using this model: The custom radio buttons are working well with various browsers and are accessible with Jaws. However, I encountered an issue when trying to use Voice Over as the radio button canno ...