Safari and Chrome render flexbox layouts differently

I am encountering a frustrating issue with my font "History Maps" centering within its title box on Chrome using flexbox, but failing to do so in the Safari browser. For reference:

Below is the HTML and CSS code in question:

 /* Parent elements */ 
    html,body {
    
    height:100%;
    }
    
    /* Setting the container-fluid, row, and column classes to occupy 100% of the html and body elements */ 
    .container-fluid,.row, .col-md-6, .col-xs-10 {
    height:100%;
    }
    
    
    #titleframe {
    
    position:relative;
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;/* Flex-box ensures font is centered both vertically and horizontally within the title frame using align-items and justify-content. See http://stackoverflow.com/questions/5703552/css-center-text-horizontal-and-vertical-inside-a-div-block */
        -webkit-box-align:center;
        -ms-flex-align:center;
        align-items:center;
        -webkit-box-pack:center;
        -ms-flex-pack:center;
        justify-content:center;  
        max-width:100%; /* Ensuring background does not stretch outside container div */ 
        height:15%;   /* Relative to parent elements (.container-fluid,.row, .col-md-6, .col-xs-10 all set to 100%) */  
        border-style:solid;
        border-width:2px;
        border-color:black;
        
        background: url("../img/pages/frame4.3.jpg");
        background-size: 100% 100%; /* Background image fills 100% of container in both x and y directions. See: http://stackoverflow.com/questions/15160764/background-image-stretch-y-axis-only-keep-repeat-x */
        background-repeat:no-repeat;
        
    }
    
    #titlepaper {
    
        position:absolute;    
        top:0px;
        left:0px;
        right:0px;
        bottom:0px;    
        width:100%; 
        height:100%; 
        border-style:solid;
        border-width:2px;
        border-color:black;
        padding: 2% 5.5% 2% 5%; 
        
    }
    
    #maintitle {
    
        position:absolute;   
        font-family:"Roboto Condensed", sans-serif;
        font-style:italic;
        font-weight: 700;
        color: black;
        text-shadow: 0px 3px 0px #b2a98f,
                     0px 14px 10px rgba(0,0,0,0.15),
                     0px 24px 2px rgba(0,0,0,0.1),
                     0px 34px 30px rgba(0,0,0,0.1);
        
        word-wrap:break-word;   
        font-size:50px; 
        width:500px;
        text-align: center;
        flex:1; 
    
    
    }
    
    @media only screen and (max-device-width : 480px) {
    
    
    
    #maintitle {
    
    font-size:30px;
    
    width:200px; 
     
    
    }
    
    }
<!DOCTYPE html>

<html lang = "en">

    <head>

        <link href="/css/bootstrap.min.css" rel="stylesheet"/>

<meta charset = "utf-8"> 

<meta name="viewport" content = "width=device-width, initial-scale = 1">

        <link href="/css/welcome.css?parameter=2" rel="stylesheet"/>
        
        <title>History Maps</title>

        <script src="/js/jquery-1.11.3.min.js"></script>

        <script src="/js/bootstrap.min.js"></script>

    </head>
    
    <body>
    
    <div class = "container-fluid" style = "border:solid;">
    
    <div class = "row" style = "margin-top:5%">
    <div class = "col-md-offset-3 col-md-6 col-xs-offset-1 col-xs-10" >
    <div id = "titleframe">
    <img id ="titlepaper" class = "img-fluid" src="img/pages/paper.jpg">
    <font id="maintitle">History Maps</font> 
    </div>
        
    </div> 
    
    </div>
    
    </div>
    
    </body>
    
</html>

If you have insight into why the font-centering behavior differs between Chrome and Safari, I would greatly appreciate any guidance.

Best Regards

Answer №1

To resolve the issue, consider either eliminating position: absolute; from #maintitle or modifying it to relative.

/* Parent elements */ 
html,body {

    height:100%;
}

/* Ensures that container-fluid, row, and column classes occupy 100% of the html and body elements */ 
.container-fluid,.row, .col-md-6, .col-xs-10 {
    height:100%;
}



#titleframe {

    position:relative;
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;/* Utilizing Flex-box ensures that text is centered both vertically and horizontally within the title frame using align-items and justify-content. Refer to http://stackoverflow.com/questions/5703552/css-center-text-horizontal-and-vertical-inside-a-div-block */
    -webkit-box-align:center;
    -ms-flex-align:center;
    align-items:center;
    -webkit-box-pack:center;
    -ms-flex-pack:center;
    justify-content:center;  
    max-width:100%; /* Prevents background from extending outside the container div */ 
    height:15%;   /* Indicates height relative to parent elements - such as .container-fluid,.row, .col-md-6, .col-xs-10 all set to 100% */  
    border-style:solid;
    border-width:2px;
    border-color:black;

    background: url("../img/pages/frame4.3.jpg");
    background-size: 100% 100%; /* Adjusts background image to fill 100% of the container in both x and y directions. See: http://stackoverflow.com/questions/15160764/background-image-stretch-y-axis-only-keep-repeat-x */
    background-repeat:no-repeat;

}

#titlepaper {

    position:absolute;    
    top:0px;
    left:0px;
    right:0px;
    bottom:0px;    
    width:100%; 
    height:100%; 
    border-style:solid;
    border-width:2px;
    border-color:black;
    /*padding:12px 25px;*/
    padding: 2% 5.5% 2% 5%; 

}

#maintitle {

    position:relative;   
    font-family:"Roboto Condensed", sans-serif;
    font-style:italic;
    font-weight: 700;
    color: black;
    text-shadow: 0px 3px 0px #b2a98f,
                 0px 14px 10px rgba(0,0,0,0.15),
                 0px 24px 2px rgba(0,0,0,0.1),
                 0px 34px 30px rgba(0,0,0,0.1);

    word-wrap:break-word;   
    font-size:50px; 
    width:500px;
    text-align: center;
    flex:1;
}

/* All media break-points: https://responsivedesign.is/develop/browser-feature-support/media-queries-for-common-device-breakpoints */
@media only screen and (max-device-width : 480px) {

    /* Styles */
    #maintitle {

        font-size:30px;

        width:200px; 


    }

}
<div class = "container-fluid" style = "border:solid;">

        <div class = "row" style = "margin-top:5%">
            <div class = "col-md-offset-3 col-md-6 col-xs-offset-1 col-xs-10" >
                <!--
                <img id = "titleframe" src="../img/pages/frame4.3.jpg" class="img-fluid" alt="Responsive image" style = "height:auto; max-width:100%;">

<img id ="titlepaper" src="img/pages/paper.jpg" class="img-fluid">-->
                    <div id = "titleframe">
                        <img id ="titlepaper" class = "img-fluid" src="img/pages/paper.jpg">
                        <font id="maintitle">History Maps</font>                
                    </div>
                    <!--<div class = "container-fluid" id = "test"></div>-->

                </div>

            </div>

        </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

Unknown CSS element discovered: bootstrap, gradient, carousel

I recently created a random quote app using javascript, jQuery, and bootstrap on Codepen. Everything worked perfectly there. However, when I organized the files, pushed them to git, and tried to view the app from Safari, I encountered some warnings and t ...

Put the title tag within a script in the shell

Within an HTML snippet, I currently have a <title> tag that I need to change on a monthly basis when generating reports. While I can manually update it each month, I am looking for a way to automate this process so the title reflects the relevant rep ...

Add design to the footer during a specific event using Javascript

Here is the CSS code I am working with: .footer { font-family: "lato", sans-serif; padding: 20px; line-height: 1.2; text-align: right; background: #eee; color: #0D47A1; font-size: 13px; height: 80px; position: fixed; right: 0px; botto ...

What is the best way to center elements within a Bootstrap dropdown menu that have become misaligned because of varying widths of icons preceding them?

I am currently working on a Bootstrap 4 dropdown menu where the clickable items consist of an icon and short text positioned next to the icon. I attempted to align both the icons and text within each element using a table layout, but it seems that the drop ...

Django is experiencing difficulties showcasing static images and loading CSS files

Working with PyCharm 2019.2.5, Python 3.7, and Django 2.2.5, I am in the process of developing a website by importing a template and creating apps for it through Django. However, I am facing issues with the static files not loading properly. Despite runnin ...

Utilize data attributes in VueJS to dynamically style elements

Is there a way to utilize the data() values within the <style>..</style> section? I have experimented with different combinations (using/omitting this, with/without {{brackets}}, etc.) but haven't been successful. Interestingly, when I man ...

Liquid backdrop centered immobile elements

I'm facing some challenges trying to figure out the most efficient and correct way to achieve this layout, similar to Stack Overflow's design. I want a header with a background color that spans the entire width of the page, while keeping the cont ...

motion graphic border not joining at the corner

Yesterday, my code was functioning perfectly. However, after making several revisions to include all animations and styles, I notice that the animated borders no longer connect at three corners. Can someone please assist in identifying what went wrong duri ...

Exploring the combination of Tailwind CSS variants with Framer Motion capabilities

Is it possible to integrate tailwind css classes with framer motion objects effectively? const variant = { hidden: { 'w-0' }, visible: { width: 400, transition: { type: 'spring', stiffness: ...

Restrict the HTML date input to only allow selection of the current date

In my form, I have set an input type date that is restricted to today's date by using the min and max attributes with JavaScript. The issue is that users are still able to manually input a different date instead of selecting it from the calendar popup ...

Incorporating a navigation bar at the top and a sidebar on the left side of the lower half of an HTML webpage

Currently utilizing materializecss and bootstrap, I am aiming to create a design that resembles: --------------------------------- --------------------------------- | | | | The objective is to split the page into two horizontal sections. The ...

Upgrading to SVG icons from font icons - Eliminate inline formatting

After making the decision to transition from font icons to SVG icons, I used Adobe Illustrator to create my SVGs and exported each individual icon using the following settings: Styling: Inline Style Font: SVG Images: Embed Object IDs: Layer Names Decimal ...

Issues arise with AJAX authentication request

Currently, I'm working on incorporating a basic login form with an AJAX request that forwards the user to a page for querying my database. Depending on the results, the user is then redirected to the main index page or prompted back to the login form. ...

The drop-down menu and input fields must have an opaque background, not transparent

I'm currently working on a Google clone project, and I've run into an issue with the dropdown menu. It looks fine when the viewport width is wide enough, but it becomes transparent and hides behind the input field when the viewport is small, as s ...

Function in view.py of Django template not being called by Python method

I have been attempting to invoke a Python view method called res() in a Django template, but it doesn't seem to be working. This is the code for my View: class make_incrementor(object): def __init__(self, start): self.count=start ...

display div only if the adjacent element does not contain a specific class

I have a situation with two divs, one of which has the class "d-none": <div class="inexistente"> Ainda não existem documentos adicionados </div> <div class="existentes d-none"></div> ...

Display a specific section of an image as the background in a div, with the image scaled and positioned perfectly

Utilizing a 1900 x 1080 image within a div as the background <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <style> html,body { height:100%; } #imageHolder{ ...

I am interested in implementing a variable to define rows within a <tr> element in an HTML table

I am facing an issue with finding specific rows in a table by using a variable like /tr[i]/ where i represents the row I want to access. When I hardcode the element in my code, it works perfectly: driver.find_element_by_xpath("//tbody[@class='sample& ...

How to refresh the page when pausing the YouTube iframe API

I'm encountering an issue with my code where I am trying to refresh the page when exiting or pausing full screen mode. Exiting full screen is working as expected, however, pausing using the YouTube iframe API's "onstatechange" event does not seem ...

Comparison of button text alignment: stacking vs inline placement

I currently have a button on my webpage labeled "Learn More." Unfortunately, the text on the button is not lining up as it should. Instead of flowing in a line, the text seems to be stacking on top of each other. The HTML code for the button is included ...