What impact does the margin have on the alignment of my inline-block divs at the top using flex-start?

Embarking on my journey with CSS and HTML, I am eager to enhance my understanding.

While attempting to align 3 divs in an inline block at the top of the flexbox section, I expected "align-items: flex-start;" to work, but unfortunately, the divs did not respond as desired. After exploring various options, adding "margin:1vmax;" to the div attributes made it work. What is the reason behind this? What fundamental principle is at play here?

        section{
            background:cadetblue;
            padding: 20px 20px;
            display: flex;
            flex-direction: row;
            align-items: flex-start;
        }

        div{
            background:black;
            color: white;
            height:auto;
            width: 25%;
            padding: 0.5em 2em;
            margin:1vmax;
            text-align: justify;
            text-justify:inter-word;


        } 

Answer №1

        Greetings! The issue in the code is due to the absence of content within the div elements, which is why you are unable to observe any difference.

          <section>
            <div></div>
                <div> Your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array and ultimately becomes the final, single resulting value.</div>
            <div> sfsdfsfs s sf sf s s saf sa saf</div>

          </section>

     section{
                background:cadetblue;
                padding: 20px 20px;
                display: flex;
                flex-direction: row;
                align-items: flex-start;
            }

            div{
                background:black;
                color: white;
                height:auto;
                width: 25%;
                padding: 0.5em 2em;
                margin:1vmax;
                text-align: justify;
                text-justify:inter-word;
            } 

check out the live example here: https://jsbin.com/yevipowusi/edit?html,css,js,output

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

Looking to reposition the control buttons above the slider in easySlider 1.7?

I am thoroughly enjoying the easySlider 1.7 and found it incredibly simple to implement. The only modification I wish to make is to relocate the next and previous buttons above the slider instead of below it. Does anyone have any suggestions on how to achi ...

Tips for customizing the focus style of a Text Field in Material-UI

My current Search box design is represented in the following image: https://i.sstatic.net/VuKIp.png I am looking for ways to customize the background color, border, and icon of the search box when it is focused. Additionally, I would like to know how to m ...

Tips for configuring the tooltip feature in Bootstrap Select plugin

I've been struggling to set the tooltip for a bootstrap select control, but I haven't been able to figure it out yet. In my situation, I have a select control without a label (due to the design of the page). So, when a user hovers over a selecte ...

Submit information into mysql using an html form (and beyond)

Hey there! I'm new to the world of MYSQL/PHP and currently working on a simple script to enhance my skills in php/mysql. However, I've hit a few roadblocks along the way. I apologize if some of these questions have already been asked before, but ...

Error encountered: string literal not closed while attempting to load text using ajax

It appears that many programmers from various languages have encountered this issue. I am using jQuery to fetch AJAX text onto a screen, but firebug is indicating an unterminated string literal with an unhelpful example : $("#content").html("<div cla ...

Deactivating all HTML DOM elements except for those with a specific #id

Currently, my goal is to deactivate all elements on an html page while keeping certain elements active. $('body').find('*').attr('onclick',"return false;"); //Deactivating all elements // I am attempting to activate the eleme ...

Load Angular template dynamically within the Component decorator

I am interested in dynamically loading an angular template, and this is what I have so far: import { getHTMLTemplate } from './util'; const dynamicTemplate = getHTMLTemplate(); @Component({ selector: 'app-button', // templat ...

Tips on creating a blurred background effect when an HTML popup modal is activated

Whenever I click on a button, a popup window appears. What I want is for the background to be blurred when this popup modal opens. <div class="modal" id="myModal"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

"Enhancing web design with jQuery mousemove to dynamically adjust CSS filters according to mouse location

I'm attempting to create a simple mousemove event that changes the CSS filter property of my background div based on the position of the mouse. While I have successfully achieved this in the past with background-color, I am now encountering issues wit ...

Are there any React-UI libraries that come with a stylish green color scheme?

Currently working on a small React site and deciding on a UI library. While I do like Material UI and Bootstrap, I find that they have limited default themes available. I am looking for libraries with green-color-based themes or ones that make it easy to ...

Enhancing the Appearance of Your Website with Yii

My Yii Website is nearly finished and I'm looking to revamp the default styling completely. Are there any recommended templates I can use, and what would be the most effective way to get started on the redesign? ...

Is it possible to showcase CSS and JavaScript code exactly as it appears when the files are saved in their respective formats, but embedded within an HTML

Recently, I've been working with notepad++ and have come across an interesting challenge. In my index.html file, I have embedded css and javascript code. Is there a way to display this code as it appears when saved in their respective files, but maint ...

A guide on implementing a Material UI table to display one row at a time on each page

I'm currently working on incorporating a Material UI table to showcase content with just one row per page. After successfully loading the page and displaying the first row, I encountered an issue where navigating to subsequent pages does not render a ...

Why won't my button's text resize?

I am facing an issue with my button's CSS code. In Chrome, when I resize the window to view the mobile layout, the text overflows outside of the div. a.syntra-green-button { background-color: #6faf3c; border: 1px solid #9dcc77; color: w ...

Trouble with Bootstrap Modal not closing properly in Chrome and Safari

ISSUE: I'm facing a problem where clicking on the X (font awesome icon) doesn't close the modal popup as expected. https://i.sstatic.net/yXnwA.jpg LIMITED FUNCTIONALITY ON CERTAIN BROWSERS: Currently, the X button for closing the modal works o ...

The issue of CSS and PHP header include file not adjusting to device size and exceeding the full width of the screen

This included code is a snippet from a header file for a website. <head> <link rel="shortcut icon" href="favicon.ico"> <meta charset="utf-8" /> <title>Test Site | Foo The Bar </title> <link rel="stylesheet" href="csss_stan ...

Create a modal using only HTML and CSS, no Javascript

Is it possible to create a modal using only HTML and CSS, without any JavaScript? I'm working on a project where I cannot use JavaScript but I still need a modal. <!DOCTYPE html> <html> <title>Minimal Modal Design</title> < ...

Embed the WordPress header file outside of the WordPress platform

Recently diving into the world of WordPress, I am eager to integrate the WordPress header file into my PHP file in order to display the identical header as seen on the WordPress site. I am exploring potential methods to achieve this as I work on creating ...

Iframe Interactivity

My goal is to create an interactive iframe that will match the current parent URL (). For example, if I have an iframe pointing to http://www.google.com and click a link within the iframe, it should update the parent URL to , and then load the clicked con ...

Implementing checkboxes before the label text using jQuery

Below is the code for a function I am working on: addCheckbox: function (name, parent, value, text) { var div = jQuery("#" + parent); var input = jQuery(document.createElement('input')).attr({ id: "cbid_" + value, name: n ...