Unable to align text in the middle of the header

Seeking help with my design flaws, I have created a fiddle to showcase the issues that arise when attempting to make it responsive. The main problem is that the HEADING IN CENTER text is not aligned properly in the center. If I remove the position attribute, the text aligns but loses its white color due to the overlay used. Additionally, clicking on the hamburger icon reveals excessive white space at the top of the page. How can these issues be resolved?

The framework used is Semantic UI.

html

<div class="ui grid nav">
  <div class="computer tablet only row computer-menu">
    <div class="ui inverted text fixed menu navbar page grid">
      <a href="" class="brand item">LOGO</a>
      <div class="right menu open">
        <a href="" class="menu item">
            <i class="content icon"></i>
        </a>
      </div>
    </div>
    <div class="ui vertical navbar menu">
        <a href="" class="active item">Home</a>
        <a href="" class="item">Blog</a>
        <a href="" class="item">Discussion</a>
    </div>
  </div>
  <div class="mobile only row mobile-menu">
      <div class="ui inverted fixed navbar text menu">
          <a href="" class="brand item">LOGO</a>
          <div class="right menu open">
              <a href="" class="menu item">
                  <i class="content icon"></i>
              </a>
          </div>
      </div>
      <div class="ui vertical navbar menu">
          <a href="" class="active item">Home</a>
          <a href="" class="item">Blog</a>
          <a href="" class="item">Discussion</a>
      </div>
  </div>
</div>
    <div class="ui main-segment">
  <section class="home-header show">
    <div class="overlay"></div>
    <div class="short-intro">
      <h1>HEADING IN CENTER</h1>
    </div>
    <div class="invitation">

    </div>
  </section>
 </div>

css

body {
  background: #e8e8e8;
}

.ui.inverted.menu{
  background: transparent !important;
}

@media (max-width: 767px) {
    .ui.grid.main{
        margin-top: 70px;
    }

  .ui.grid { margin: 0 !important; }
    .ui.vertical.menu.navbar{
        margin-top: 0px !important;
    }
}

.main-segment{
  padding: 0 !important;
}

.ui.vertical.menu{
    margin-top: 45px !important;
    width: 100%;
    display: none;
  background: rgb(32, 85, 109);
}

.vertical.menu a.item{
  color: #fff !important;
}

.computer-menu, .mobile-menu{
  padding-bottom: 0 !important;
}

.ui.grid+.grid {
     margin-top: 0 !important;
}

.ui.menu {
    font-size: 2rem;
    text-align: center;
}

.ui.grid.nav>.row{
  padding: 0 !important;
}

/* */
.ui.grid>*{
     padding-left: 0 !important;
     padding-right: 0 !important;
}

/* MENU */
.menu {
  float: right;
}

section.home-header.show {
    background: url('http://www.ics.com/sites/default/files/iot.jpg') center;
}

section.home-header {
    background: #000;
    background-size: cover;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 1;
    -moz-transition: 2s background-color;
    -o-transition: 2s background-color;
    -webkit-transition: 2s background-color;
    transition: 2s background-color;
}

.overlay {
    position: absolute;
    z-index: 2;
    background: url(../img/pattern.png),rgba(0,0,0,.5);
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

request-invitation {
    background: #fff;
    z-index: 100;
    width: 25%;
    position: absolute;
    top: 50%;
    padding: 25px;
    color: rgba(27, 28, 29, 0.77);
    text-decoration: underline;
}

.short-intro {
    color: #fff;
    position: absolute;
    z-index: 100;
    font-weight: 900;
    text-align: center;
    margin: 10em 20em;
    /* left: 50%; */
}

.short-intro h1 {
    font-size: 4em;
}

Access the jsfiddle link here.

UPDATE

An amendment has been made in the CSS code where .connyct-short-intro was changed to .short-intro. You can view the updated fiddle to observe that text alignment is possible using position: absolute for maintaining the white color scheme.

Answer №1

modify the class below

.short-intro h1 {
    font-size: 4em;
    text-align:center
}

does this meet your requirements? view demo here

LATEST UPDATE

still trying to grasp your issue, check out this updated version

FINAL UPDATE

successfully resolved top space problem see changes here

Answer №2

Implement the style rule text-align: center to the element with the class name - short-intro

.short-intro {
  text-align:center;
}

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

I'm curious about where to find more information on this new technology called the 'scroll to page' feature

Recently, I came across a captivating website feature that caught my eye. As someone relatively new to front end web development, I am intrigued by the scrolling technique used on this site. I'm specifically drawn to the 'page to page' scro ...

Problem encountered when incorporating PHP code into HTML

I have a PHP forum and an HTML website that I am trying to merge for a cohesive appearance. However, I have encountered an issue when attempting to integrate the PHP code into the HTML file. Despite using the following code: <?php echo "here goes my P ...

JavaScript causing attribute() variable to malfunction in CSS animation

I am attempting to implement a CSS animation using three files. Below is the HTML file: <html lang="en"> <head> <link rel="stylesheet" type="text/css" class = "tag" href="../css/style.css" ...

ng-click-outside event triggers when clicking outside, including within child elements

I am looking to trigger a specific action when I click outside of the container. To achieve this, I have utilized the ng-click-outside directive which works well in most cases. However, there is one scenario where an issue arises. Inside the container, the ...

"Utilizing the ng-class directive in AngularJS to apply multiple

I have been attempting to utilize the ng-class directive in AngularJS based on a certain condition: if a JSON value is 1, it should display as green; if it's 2, red; and if it's 0, white. However, I am unable to achieve the desired result for som ...

Pattern for Ajax callback in Javascript

I'm facing an issue with the code snippet below. var bar = { ajaxcall : function(){ var _obj = {}; $.ajax({ headers: { 'Content-Type': "application/json; charset=utf-8", 'da ...

Tips for positioning a box on top of a map in a floating manner

I am trying to figure out how to position the div with class box on top of the map in this jsbin. Can someone help me achieve this? Below is the CSS code I have for styling the box and body. body { font-family: "Helvetica Neue", Helvetica, sans-serif; ...

What is the best way to customize a div depending on the validation status of all reactive form fields within it?

I am facing a challenge with a rather complex form that contains multiple fields. Some of these fields are used to create logical blocks, and I would like to emphasize the surrounding div if any of these included fields are invalid. Can you suggest the bes ...

The behavior of a fixed position in Flexbox varies when comparing Chrome to Safari and Firefox

In Chrome, the following code works as expected, with the list element positioning itself at the very left of the .PageContainer when scrolling down. However, in Safari and Firefox, the list element positions itself just after the logo. Are there any CSS r ...

The placement of the floating element completely messes up the

Whenever I try to float an element in my magnificent popup, the layout gets all messed up. You can see for yourself by trying to put the image and text next to each other using "float: left": http://jsfiddle.net/a7Vj8/1/ Every time I attempt to float th ...

Is it possible to transfer data to the next page by clicking on a table row?

I'm facing an issue with a non-clickable table. When a row is clicked, I want to navigate to a detail page from the table while passing the id value in the process. I know that I need to create an href attribute on the table row and somehow transfer ...

What is the best way to adjust the scroll speed within a specific element using React?

Hey there, I'm currently working on adjusting the scroll animation of a div (MUI Container) to make it smoother and slower. I've spent some time searching online for a solution but haven't found anything helpful so far... By the way, I' ...

Employ gulp for rebasing CSS URLs

I have a question regarding how to resolve the following issue: In my sass files, I utilize absolute path variables in my main include files. For example, fonts are stored in /assets/fonts/... and icons are located in /assets/icons/... These paths only wo ...

Refresh the dropdown menu selection to the default option

My HTML dropdown menu includes a default option along with dynamically generated options using ng-options. The variable dropdown is bound to the dynamic options, not the default one. <td> <select ng-model="dropdown" ng-options="item as item.n ...

Formatting dynamically generated HTML using C#

My ASP.NET web forms site has a large menu that is dynamically generated using C# as a string. The HTML code returned looks something like this: <ul><li><a href='default.aspx?param=1&anotherparam=2'>LINK</a></li> ...

The asynchronous ajax request is leading to a browser freeze

In the HTML page, I have two sets of a and p elements that are initially set to display:none. At the bottom of the page, there is a function being called with their respective ID's and values, which will enable one of them based on certain conditions ...

"Major issues arise as CSS3 Animation fails to function properly across all web

I have been experimenting with using a sprite and CSS3 animation to create a rollover effect. While it seems to be working in CODA 2, I'm encountering issues when testing in Mozilla, Chrome, Safari, and Opera as the animation fails to trigger. /*link ...

The URL "http://packagist.org/p/provider-3.json" was unable to be retrieved due to a bad request error (HTTP/1.1 400 Bad Request)

Encountering a 400 bad request issue when trying to connect over HTTP, despite the package only being installable via HTTP. Attempting to override in composer.json to force HTTPS as suggested by others for a workaround, but that solution doesn't seem ...

Is it possible to utilize a contenteditable div in place of a textarea?

Is it possible to replace a textarea with a content editable div? Will the behavior be the same? Can data processing be done in the same way as with textarea data? ...

Finding attributes with spaces in their values using XPath

Is there a way to select an attribute with spaces in xpath? I am currently trying to select a checkbox attribute named "checked type". I have experimented with //[@checked type], //[@checked-type], //[@checked_type], and //[@checked\stype], but none ...