What is the best way to position two images side by side at the bottom of my Div Box?

I am tackling the challenge of creating an about page. I have successfully added text at the top, but I'm struggling with aligning two images side by side at the bottom. No matter what I try, they always end up stacked on top of each other. My goal is for both images to be the same size and together take up 50% of the width of the Div box. This project is a big one for me as a novice in HTML.

Here's the code snippet where I'm encountering the issue:

[Insert code here]

Answer №1

The reason for the issue is that by setting width: 60% on each div, the total exceeds 100%. To fix this, change the width to 50% and use float:left instead of display:inline-block, followed by clear:both. Below is the updated code:

<div class="article">
    <img src="Our Gadgets.jpg" class="img-1" alt=""/></div>
<div class="article">
    <img src="Trap.jpg" class="img-2" alt=""/>
</div>

<div class="clear"></div>

.article {
 float:left;
 width: 50%;
 height: 100px;
 overflow: hidden;
}

img {
 width: 100%;
 height: 50%;
}

Answer №2

Implement

.blog-post{
   width: 50%;
   float: left;
 }

Answer №3

For example, it is important to avoid using white spaces in image sources (src="Our Gadgets.jpg"). Instead, use a forward slash or underscore.

HTML

<div class="images">
<img src="http://www.modafinilsale.com/data/out/789/231770955-random-desktop-wallpaper.jpg" alt="">
<img src="http://www.modafinilsale.com/data/out/789/231770955-random-desktop-wallpaper.jpg" alt="">
</div>

CSS

.images img {
display: block;
width: 50%;
float: left;
}

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

Implement a dialog on top of a current web page, achieve php-ajax query result, and enhance with

My website features 'dynamic' content, where 'static' nav-buttons replace specific div contents upon clicking. While I am able to retrieve my php/ajax results in a dialog box, I am struggling with placing this dialog above my current p ...

The make-xx-column() mixins in Bootstrap are malfunctioning

After careful examination, it looks like some of the Bootstrap mixins are not functioning as expected. Specifically, the .make-md-column() and .make-sm-column() seem to have no effect at all. Initially, I suspected that WebEssentials was not compiling the ...

Crafting a unique rounded rectangle with an Inverted S-curve design using CSS and HTML

In an attempt to replicate the design showcased in the image provided via link, I am working on creating a rounded rectangle with an "S-curve" effect at the bottom. To achieve this, my current approach involves utilizing a parent element (hero_right) with ...

The Angular ng-repeat directive is populating a list with items, but the parameters enclosed in double curly braces

After calling an API, the response contains data in the following format: [{name: "ABC", age: 20}, {name: "DEF", age: 25}] Even though the $scope.names variable is assigned with the array from the API, when viewed in the browser, it displays 2 rows but th ...

What is causing the dysfunction of angular2 form when used with the HTML <form> tag?

Can someone explain the strange behavior of the <form> element in ng2 to me? I have noticed something odd and need some clarification :) To demonstrate, I have created a simple Plunker example at this link: https://plnkr.co/edit/vdrHJBNdd26y6YhPXTHD ...

What is the best way to utilize Selenium for choosing an item from a drop-down menu?

My current challenge involves using Selenium to interact with a dropdown menu in Python. The HTML snippet below shows the structure of the website I'm working on. <select data-id="1388874259461-k9k0y" name="walletselectedbitcoin" id="selectWallet" ...

Using jQuery's append function, you can dynamically generate a dropdown list in PHP code

One of the challenges I'm facing is related to a button that, when clicked by a user, should append a dropdown list to the HTML. I am using PHP to retrieve data from a database and fill the dropdown list with it. However, upon trying out this code, it ...

How can I prevent the expansion of elements in a drop-down menu when using display:

I've been struggling to implement a drop-down feature in my menu. The issue is that when I use display: flex, hovering over the drop-down also expands all other boxes without drop-downs. Any ideas on how to fix this easily? Additionally, is there a w ...

Changing the color of child divs on rollover in a parent div

When I hover over my parent div containing 3 child divs, only parts of the child divs change color. How do I make all the child divs change color when part mouse is hovered over them? Any help would be appreciated. Thanks! This is the code I have attempte ...

Using jQuery to show array elements with unique formatting or separator

Using the jQuery map/get function, I am able to retrieve an array of values from multiple checked checkboxes: $('input[type=checkbox]:checked').map(function(_, el) { return $(el).val(); }).get(); After executing this code, I will get an arr ...

Arranging divs in a horizontal line while keeping the content organized in a vertical manner within the footer

I've been searching for a while now, but I haven't found any solutions that actually work. This might be repetitive, so my apologies in advance. The issue at hand is aligning three divs horizontally to create a footer, while maintaining a vertic ...

Issue with React rendering numbers without displaying div

In my user interface, I am attempting to display each box with a 1-second delay (Box1 after 1 second, Box2 after another 1 second, and so on). https://i.sstatic.net/FdTkY.png However, instead of the desired result, I am seeing something different: https ...

Tailwindcss's responsive design suffers from sluggish performance

Currently, I am working on creating a blog using Next.js and I am looking for a way to display or hide the Table of Contents (TOC) based on responsiveness requirements. Although I am utilizing Tailwind CSS for styling, I am experiencing slow reactions. I ...

What is the best way to expand my navigation bar to fill the entire width of my div?

A big shoutout to @seva.rubbo for fixing the issue! Check out the updated code on JSFiddle I recently designed a layout with a fixed width div of width: 900px;. I centered this div, leaving blank spaces on either side. Now, I'm looking to add a navig ...

Implementing a Dialog Box for Confirmation

I want to include a "confirmation box" that will display the message "Are you sure you want to update/delete question?" when I press the "update" and/or "delete" buttons. I attempted to add onclick="return confirm('Are you sure you want to logout?& ...

How to execute a JavaScript function within a Jinja for loop

I am currently working on an HTML page where the variable schedule contains a series of sequential decimal numbers representing seconds. My goal is to develop a function in JavaScript/jQuery that can convert these decimal numbers into time format. However ...

Protection of Angular expressions

I have been following the PhoneCat tutorial for AngularJS and found it very helpful up until step 6 where links are generated dynamically from angular expressions: http://localhost:8000/app/{{phone.imageUrl}} Although the tutorial mentions that ngSrc pre ...

Steps for positioning a div with list items to match the height of its parent container

I've been grappling with this problem for a long time now. Within the parent div "wrapper," there is a child div called "sidebar-wrapper" that contains an ul with li elements. I'm trying to make the height of "sidebar-wrapper" adjust to match t ...

Boosting Your SCSS (SASS) Productivity

I'm curious if there are any ways to make the code below more efficient or dynamic. I've already achieved the desired result, but I'm interested in optimizing it further. The Script Any suggestions would be highly appreciated, Cheers, ...

Position the iframe at the center of the image for the best display

I'm looking for a way to make my web app appear as if it is on an Android or iPhone device. I've explored various solutions, but they all have their drawbacks. My workaround involves loading the web app in the middle of an iframe, which is then p ...