Change the width of a div element without causing text to wrap when resizing the browser window

Looking to create a layout with three div elements, each containing an h1 element. The goal is to have the first div on the left side, the second div in the center, and the third div on the right side, all in a single row. When the window is resized for responsiveness, the text should adjust by minimizing or maximizing the gap between each div, without breaking into two lines. Currently, the three div elements are positioned very close to each other. This code snippet shows how it's structured:

<div style="display:inline-block;">
    <h1 style="color: white;">Yaqoob Yawar</h1>
</div>

<div style="display:inline-block;">
    <img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar">
</div>

<div style="display:inline-block;">
    <h1 style="color: white;">یعقوب یاور</h1>
</div>

To see this layout in action, visit: yaqoobyawar.com

Answer №1

Revamp your current HTML

<div class="slot-c">
    <div style="display:inline-block;">
        <h1 style="color: white;">Yaqoob Yawar</h1>
    </div>
    <div style="display:inline-block;">
        <img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar" scale="0">
    </div>
    <div style="display:inline-block;">
        <h1 style="color: white;">یعقوب یاور</h1>
    </div>
</div>

Replace it with this updated HTML utilizing the Bootstrap 4 Grid system.

<div class="row">
    <div class="col">
        <h1 style="color: white;">Yaqoob Yawar</h1>
    </div>
    <div class="col" style="text-align: center;">
        <img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar" scale="0">
    </div>
    <div class="col">
        <h1 style="color: white;">یعقوب یاور</h1>
    </div>
</div>

Additionally, eliminate the d-flex class from the parent div.

Answer №2

.grid-container {
display: grid;
grid-template-rows: 1fr;/* Customize the number of rows you want to create */
grid-template-columns: 1fr 1fr 1fr; /* Customize the number of columns you want to create */
}
<div class="grid-container">
<div>
    <h1 >John Doe</h1>
</div>

<div>
    <img src="https://example.com/image.jpg" alt="John Doe">
</div>

<div >
    <h1 >جان دو</h1>
</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

Error loading custom Javascript in MVC 4 view during the first page load

I'm working on an MVC 4 application that utilizes jQuery Mobile. I have my own .JS file where all the functionality is stored. However, when I navigate to a specific view and check the page source, I notice that all scripts files are loaded except fo ...

Ways to identify when a person has scrolled a specific distance

Is it possible to modify the appearance of my top navigation bar once the page has been scrolled a specific number of pixels? I assume this requires some sort of listener to track the amount of scrolling. I came across element.scrollTop, but it doesn' ...

Basic color scheme

I'm attempting to change the background color behind a partially transparent .png div. The CSS class that modifies the div is ".alert". Manually editing the .alert class background color works perfectly, and now I want to automate this on a 1-second c ...

Ways to position an absolute element in the middle of two CSS Grid cells

Is it possible to position an element with position: absolute between two grid cells, where half of the element is on the sidebar and the other half is on the rest of the page? The challenge arises when there is overflow set on both the sidebar and the pag ...

Customize the appearance of the "Collapse" component in the antd react library by overriding the default styles

Incorporating JSX syntax with *.css for my react component. Displayed below is the jsx code for the antd collapse section. <Collapse defaultActiveKey={["1"]} expandIconPosition="right" > <Panel header="This is p ...

How can I adjust the width of td based on the content they contain?

Is it possible to dynamically set the width of a <td> in a table to match the size of the largest <td> in that column while still ensuring the table remains at 100% width? Occasionally, my table doesn't reach 100% width due to empty colum ...

Updating image URL for grouped objects with Fabric JS

Check out this link :http://jsfiddle.net/mishragaurav31/ang58fcL/#base I created two groups of objects; one consisting of a circle and text, and the other with two images. When I try to change attributes for group 1, it works fine. However, when attempt ...

Modify the button transition background color in Bootstrap 4 for a new look

I am looking to customize the hover behavior of buttons on my website. By default, the buttons darken in color when hovered over. I was attempting to modify this behavior by adjusting variables in the _variables.scss file within the Bootstrap source code. ...

Refreshing content with Ajax when the back button is clicked

Hey everyone, I've been working on an ajax site and I'm having trouble getting the content to reload when the back button is clicked. I'm using Dynamic Drives ajax content script along with a script that changes the URL onclick and a popstat ...

Is there a way to prevent on-click errors in ReactJS that someone can share with me?

The onclick listener was expected to be a function, but instead received a value of string type. getListener@http://localhost:3000/static/js/bundle.js:18256:15 accumulateSinglePhaseListeners@http://localhost:3000/static/js/bundle.js:22846:39 <button on ...

When using jQuery, the onChange() function can be used to switch focus

Make sure to check out this fiddle first: http://jsfiddle.net/7Prys/ I am looking for a way to automatically focus on the next input field when a user enters a value in the previous field. This should happen until the fourth input field. Is there a simple ...

Refreshing a PNG file without the need to refresh the entire page

Developed a captcha using imagestring imagestring($image, 5, 5, 30, $text, $text_color); imagepng($image,"captcha_image.png"); imagepng($image,"captcha_image.png"); The code snippet above shows part of the implementation. <img ...

Replacing an array in Perl with the contents of a SQL database: A step-by-step guide

Update: (Check Revised Code at the bottom) The code is now functioning properly to retrieve data from 2 databases with some additional cleaning required. However, I'm facing a challenge where the code previously used: next unless $currentuser ~~ @las ...

What's the best way to position the <li> element beneath the hamburger icon?

Is there a way to place the list element 'Home' below the hamburger icon and logo in Bootstrap 4 in mobile mode? I attempted to display the logo as style="display: block" with no success. <div class="container"> <nav class="navbar nav ...

Angular does not display a loading indicator in the header

When handling service calls, I have implemented a loading indicator to provide feedback to the user. However, it appears that this indicator is not effectively preventing users from interacting with header items before the loading process is complete. My ...

Adjusting the slider with jQuery and CSS to extend beyond 100% while remaining within the div boundaries

Currently, I'm working on customizing a jQuery slider. My goal is to achieve the same functionality as the jQuery UI slider where you can set a max value like "2500" and the slider will smoothly adjust without going outside of the specified div or scr ...

What is the solution to making text appear on the top rather than on the side?

Seeking a way to keep the text description above the textbox within a definition list, however currently the text appears to the left of the box. Here is the provided HTML structure: <dl> <dt> <label>Phone Number</label> &l ...

Identify the specific element using a designated data attribute

Having trouble figuring out how to select a specific element with a particular data attribute. In my situation, I want to target the a element with class="zoom-image" and data-order-item-id="<?=$order_item_id ?>". Here is the HTML/PHP code snippet ( ...

JS and its dynamic color changes

A game has been developed using JavaScript and HTML. The game features a table with cells that are assigned IDs for toggling colors using an onClick function. The objective is simple: when a cell is clicked, all neighboring cells, including the clicked one ...

Is there a more efficient approach to applying a basic function to multiple elements within a DIV and having it activate only upon a click event using jQuery?

This solution works, but I am looking for a more professional approach in order to adhere to the principle of "don't repeat yourself." $("document").ready(function(){ $(".child").each(function(index){ $(this).click(func ...