Adjusting the width of elements using percentage values in CSS and altering the layout with Bootstrap

I am facing a peculiar issue. I have added a

d-flex justify-content-between container

to my div container with text on one side and images on the other. However, when I try changing the width using % (for example, width:5%), the flex behavior becomes strange and everything shifts to one end.

At some point, when I change the width using vh, vw or px, it works fine. But I specifically need to use %. What should I do?

JSX:

<section className='footer-area'>
        <div className='d-flex justify-content-between container'>
          <div className='address'>
            <h4><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b2304060e2b190e460d19020e050f071245080406">[email protected]</a></h4>
            <h4>ארלוזרוב 11, רמת גן</h4>
          </div>
          <div className='mw-3 share '>
            <img
              src={facebookLogo}
              className='img-fluid'
              alt='Responsive image'
              onClick={() =>
                window.open(
                  "https://www.facebook.com/"
                )
              }
            />
            <img
              src={whatsappLogo}
              className='img-fluid'
              alt='Responsive image'
              onClick={() => window.open("https://wa.me/+972505710373")}
            />
          </div>
        </div>
      </section>

CSS:

.img-fluid {
  margin: 2vh;
  max-width: 10%;
  height: auto;
}

The unusual footer display:

https://i.sstatic.net/5UkKi.png

Desired appearance: https://i.sstatic.net/FdVdL.png (achieved with vh but I require it in %)

Answer №1

When dealing with elements that have the flex property, it's important to prioritize using this property over setting a specific width.

To specify a width of 5%, you can achieve this by utilizing the following CSS code: flex: 0 0 5%;

Answer №2


  .responsive-image {
    padding: 2vh;
    maximum-width: 10%;
    height: automatic;
    position: 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

What are the strategies used by AngularJS's official website to create SEO-friendly pages?

If you're interested in seeing how AngularJS.org presents pre-rendered content to search engine bots and scrapers, take a look at http://docs.angularjs.org/?_escaped_fragment_=/tutorial/step_09 I'm intrigued by the implementation strategy used f ...

Using React to map and filter nested arrays while also removing duplicates

Hello, I recently started working with react and I've encountered a challenge while trying to map an array. const fullMen = LocationMenuStore.menuItems['menu']['headings'].map((headings: any) => { <Typography>{ ...

Django - encountering a request error while attempting to access a media file

I have set up my project with Django REST Framework for the backend and React for the frontend. One of the features includes a database where articles are uploaded, each containing a title, body, and an image. While I am able to fetch and render the title ...

Dealing with blank values in jQuery DataTables

I am currently utilizing jQuery DataTable to display data in table format; within the table, there is a button that triggers a Bootstrap Modal for editing two of these values, and I utilize Ajax to send the modified values to a Spring Controller. The init ...

Mastering the art of filtering object arrays with underscoreJS

(PROBLEM SOLVED! Check the solution in the responses) Here's my query: I am trying to filter an array of objects based on a specified object, but all my attempts have resulted in an empty array. I suspect that the issue lies in iterating over an arr ...

ReactJS not responding to Bootstrap toggler button

My Bootstrap toggler button is not working in ReactJS. I did not include the jQuery scripts because I imported Bootstrap at the top. The button should only appear and function on small devices. import React from 'react'; import 'bootstrap/d ...

Keeping the header in place: fixed positioning

This particular situation is quite challenging for me. I have a webpage that requires horizontal scrolling. There is a menu at the top of the page that needs to remain centered on the page at all times. Even with the use of jQuery, I am uncertain how to ac ...

Elevate the functionality of your table in BoostrapVue by customizing it to display items

How can I modify the code below to turn the items into input fields that the user must enter? Instead of listing the items, I would like to replace them with input fields. <template> <div> <b-form-input v-for="(item, index) in items" ...

The problem of a circular reference arose when attempting to pass the model using the JSON.stringify method

I am looking to replace all fields with null values to prevent the model from proceeding further. However, when I attempt to create a replacer function and pass the model, I am encountering a circular reference issue. Is there a more effective way to accom ...

What to do when IE6/IE7 margins disappear after moving a relatively positioned floated div using jQuery's .hover()?

Sharing my code with you: http://jsbin.com/uhera3/edit Encountered an issue where the relatively positioned floated divs move to the left in IE7 when using jQuery's .hover() function. Any insights on how to resolve this problem? ...

How to align an unordered list horizontally in HTML without knowing the number of items

I'm currently developing a web page that needs to display an unknown number of items using the ul/li HTML tag. Here are my requirements: The list should utilize as much horizontal space as possible The list must be horizontally centered, even if lin ...

The min-height property does not seem to be compatible with -webkit-calc

I've been experimenting with this code: .main{ min-height: -moz-calc(100% -50px); min-height: -webkit-calc(100% -50px); min-height: calc(100% -50px); background-color:#000; color:white; } html{ height:100%; } <html ...

How can I apply bold styling to primary nodes in jsTree using CSS?

I am currently utilizing the in conjunction with asp.net mvc. My objective is to apply bold styling to the text using CSS within the main nodes, specifically those with arrows (refer to the image below). https://i.sstatic.net/xg3uF.png Below is the code ...

Having trouble installing expo-cli globally

As someone who is new to react-native, I recently encountered an issue while setting up my project. After installing all the necessary packages and attempting to start with the npm start command, I was met with the error message 'expo-cli' is not ...

What strategies can I employ to maximize the use of my table within the entire webpage?

How do I make my table utilize the entire web page instead of being centered with margins on each side? I have a 24 inch monitor with 4 inches of margin on each side, and I thought using 'table-responsive' in Bootstrap 4 would address this issue ...

Tips for converting a styled MS-Access report to HTML with a template document

I am having trouble formatting my MS Access report using an HTML template. After doing some research, I discovered the following tags and tokens for MS Access HTML templates: <!--AccessTemplate_Body--> <!--AccessTemplate_FirstPage--> ...

Ways to adjust a column width to be equal to the full width

My HTML table has columns with fixed widths, except for one that I want to expand to fill the remaining space with a minimum width set. I attempted using width: auto, but it didn't achieve the desired result of filling the leftover space. ...

Ways to retrieve the content from a textfield

Is there a way to retrieve text from a textfield in material UI without using the onChange method? It just seems odd that I would need to constantly track the value with onChange in order to use it for any other purpose. I decided to search for solutions ...

Incorporating a new component into the table tab design with HTML

One more question to wrap up the day. Here is my current setup along with the corresponding CSS: <p>&nbsp; </p> <p>&nbsp; </p> <div class="row tab-cover"> <div class="col-sm-4"><a href="/home" target=" ...

form data not being populated in req.body

My attempt at submitting a POST request to my nodejs (express) server is not populating any data from my form in the req.body. I have searched for solutions and found that many suggest moving the bodyparser before the routes and ensuring form fields have n ...