Flexbox does not resize the image

Why is the image (#avatar) not resizing in height with flex? I tried setting its height manually and it worked. But I really want it to be done using flex.

I'm not sure if this is my mistake or a flex error...

Please add a complete sample code.

It only works when I add this to #avatar: - height: 10vh;

body{
    margin: 0;
}

.startContainer {
    width: 100vw;
    height: 100vh;
    position: absolute;
    
    background-image: url("http://i.imgur.com/NVYPtGJ.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-content: center;
    -ms-flex-line-pack: center;
    align-content: cen...
<!DOCTYPE html>
<html lang="es">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>John Doe</title>
    <link rel="stylesheet" href="css/preload.css">
    <link rel="stylesheet" href="css/index.css">
    <link href='https://fonts.googleapis.com/css?family=Press+Start+2P' rel='stylesheet' type='text/css'>

</head>

<body>
    <div class="startContainer">
        <div class="startSideItem sideContainer">
            <div class="sideItem">
                <img alt="" class="arrow" id="rotateLeft" src="http://i.imgur.com/XBejH02.png">
                <p>About Me</p>
            </div>
        </div>
        <div class="startCenterItem centerContainer">
            <div class="topBottomCenterItem"></div>
            <div class="centerItem">
                <img alt="" id="avatar" src="http://i.imgur.com/m5U9gy2.png">
            </div>
            <div class="topBottomCenterItem">
                <p>Contact</p>
                <img alt="" class="arrow" id="rotateDown" src="http://i.imgur.com/XBejH02.png">
            </div>
        </div>
        <div class="startSideItem sideContainer">
            <div class="sideItem">
                <p>Portfolio</p>
                <img alt="" class="arrow" src="http://i.imgur.com/XBejH02.png">
            </div>
        </div>

    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/jquery.gsap.min.js"></script>
<!--    <script src="js/preload.js"></script>-->
</body>

</html>

Answer №1

However, this solution is merely a temporary fix as the max-height: 100%; property is not present in the parent or image (child) elements.

Image within flex-item disregards max-height:100% in Chrome and Firefox - (functioning correctly in Safari)

Answer №2

Give this a shot:

.centerItem {
  order: 0;
  flex: 0 1 10vh;
  overflow: hidden; /*UPDATED*/
  align-self: auto;
}

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

Loop through the <li> elements and use jQuery to update the text

Check out this HTML setup: <div class="mydiv"> <ul> <li>Text 1</li> <li>Text 2</li> </ul> <ul> <li>Text 3</li> <li>Text 4</li> </ul> <ul> < ...

How to position two Bootstrap 4 Navbars side by side

I'm currently experiencing an alignment issue with two stacked navbars in my code. I want to align the upper navbar with the lower one, but I've tried various approaches without much success. Is there a problem with the buttons or something else ...

Overlap elements without using absolute positioning and prevent resizing distortion

Looking to incorporate a line with tick marks and a ball (similar to a scale) into my design. Some tutorials recommend using absolute positioning or float for this effect. While these methods work partially, I've noticed that the divs tend to shift o ...

Tips for designing a multi-level dropdown navbar

I am currently facing an issue with designing a navbar. I am aiming for Multi-Level Dropdowns, but whenever I click on More Services, it automatically closes the main dropdown menu. I have experimented with various approaches, but none of them seem to be ...

Using Express.js to serve simple SVG files (Technique involving Cheerio.js)

My goal is to manipulate SVGs before sending them through Express.js. The code snippet I am using is as follows: app.get("/iconic/styles/:style/:base/:icon", function (req, res) { var style = req.params.style; var base = req.params.base; var i ...

Creating a table to showcase the outcomes of two different conditions

I am struggling to include two conditional result statements in a table, but I can't seem to make it work. If the form input is empty, the result should not be shown. In order to save space, I would like to organize the results in a table with eithe ...

Ensuring that two elements in HTML/CSS always appear on the same line

Within my HTML code, I have implemented 2 tables using the PrimeFaces UI Framework for Java. Each table contains a button, and I am seeking a way to ensure that both buttons always appear on the same line. To achieve this alignment, I applied a style with ...

Conceal the footer using CSS while the slide is in focus

Trying to figure out a way to hide the footer when a specific container is active: For example, how can I hide the footer when the second and third items are selected as active? <div class="owl-stage"> <div class="owl-item"></div> & ...

How can I alter the appearance of the active nav tab in Bootstrap to display an underline?

I am currently utilizing the Bootstrap active tab pane, and it is displayed as shown below: https://i.sstatic.net/FJ4lt.png However, I want to customize it to look like this: https://i.sstatic.net/BUWpK.png Specifically, I aim to have the active tab un ...

Why is a <script> tag placed within a <noscript> tag?

Lately, I've been exploring various websites with unique designs and content by inspecting their source code. One site that caught my attention was Squarespace, which had blocks of <script> tags within a <noscript> tag: <!-- Page is at ...

Diagonal div sliding out from side navbar

As someone who is completely new to diagonal divs, I am looking to recreate the layout shown in the linked home page and menu. Despite spending the entire day searching online, I have been unable to find the specific information I need. That's why I a ...

Concealing a div with CSS on a WordPress site

This is the snippet of code that I need to keep hidden <div class="count"> <div class="number">1</div> <div class="text">donation</div> </div> I attempted to ...

What is the best way to make my submit button display a message according to my switch statements in JavaScript?

function displayMessage() { var message; var firstName= alert( switch(firstName) { case "Cherry": message="Thank You Cherry!! Your order should arrive 20 days from February 4, 2017"; break; case "Micheal": ...

When hovering over an image to show a text box using JavaScript, it only works on one image due to the use of getElementById

I have been experimenting with some JavaScript code to create a pop-up box that appears when you hover over images. However, I have encountered an issue where it only works for one image. I suspect this is because I have used IDs instead of classes, but I& ...

Tips for showcasing the individual product page in full width on woocommerce

Here is a link to the single product page: I am wondering if it's possible to extend the product summary drop-down menus all the way to the right without impacting the mobile site? Thank you. ...

Troubaking CSS issue with Inline-block display

I am currently troubleshooting a display issue that is visible below: Here's the HTML code: <span class="pw_brand_product_list"><div class="wb-posted_in">Brand:</div><a href="https://www.google.com">My First Brand</a>< ...

What is the proper way to utilize a variable within the translate3d function?

Currently, I am developing my portfolio and working on a function in JavaScript called translate3d(0,10px,0). My question is, how can I use a variable instead of hardcoding the value 10px? I attempted to use translate3d(0,a,0) where 'a' is a vari ...

Bootstrap / Blazor - no action when clicking on an image link

Having issues with adding a simple HTML link around an image in my Bootstrap 4.5 / Blazor app. When I click on the link, nothing happens. How is this possible? I've tried using the <a href"..."><img ...> pattern, as well as NavL ...

Extract particular XML element(s) and incorporate them into an HTML webpage

Just diving in for the first time. I hope you all can bear with me. This particular issue might have similarities with others, but from what I've gathered, this is a unique problem that I'm tackling. For your information, my expertise lies in de ...

Items that do not commence from the start of the list

I'm encountering an issue with my unordered list where the li elements are not rendering properly. The first element seems to have a margin, and I'm unsure why this is happening. How can I fix this problem? function App() { return ( < ...