Problems with the main title formatting in the header

I am currently working on a new website and have encountered an issue with the header design. The Mainline "PersIntra" is overlapping the "log out button" box, which I would like to be positioned beside it instead.

Despite my efforts with CSS and nesting divs, I cannot seem to get the layout right. The header has become too wide vertically, and increasing the text size of the headline only makes it worse by causing it to overlap the logout box.

To better illustrate my problem, please refer to these screenshots.

The website is in Danish, but language shouldn't hinder your understanding of the issue (as shown in the screenshots).

Below is the HTML code:

<div id="header">
            <h2> PersIntra </h2>
        
        
            <div id="border">
            Velkommen <?php echo $_SESSION['enummer']; ?> <br>
            Du har 1 ny besked <br>
            <a href="logout.php" style="color: white">Log Ud</a> <br>
            </div>
            
        </div>
        </div>

And here is the corresponding CSS:

#header {
    background-color:#66cc33;
    color:white;
    text-align:center;
    padding:5px;
    border: 10px solid;
    border-radius: 25px;
}

#border {
    width: 150px;
    padding: 5px;
    border: 5px solid navy;
    margin: 25px;
    border-style: solid;
    border-color: #eeeeee;
}

Answer №1

Consider modifying your css styling.

#nav {
    background-color:#3399ff;
    color:black;
    text-align:center;
    padding:10px;
    border: 15px solid;
    border-radius: 30px;
}

#nav h2 {
    margin-top:50px;
    float:left;
    margin-left:200px;    
}

#border {
    width: 180px;
    padding: 10px;
    border: 8px solid teal;
    margin: 35px;
    border-style: dashed;
    border-color: #cccccc;
}

Answer №2

There are a variety of methods to achieve this type of layout. One approach is to float the header to the left and have it displayed inline with the login box, as shown below:

#header {
    background-color:#66cc33;
    color:white;
    text-align:center;
    padding:5px;
    border: 10px solid;
    border-radius: 25px;
}
h2 {
  float: left;
  display: inline;
  width: 80%;
  font-size: 2em;
}
#border {
  display: inline;
  width: 20%;
    width: 150px;
    padding: 5px;
    border: 5px solid navy;
    margin: 25px;
    border-style: solid;
    border-color: #eeeeee;
}

If you're looking for a quick solution, you may want to consider using a CSS framework like bootstrap (http://getbootstrap.com/). If your goal is to learn more about CSS, I suggest downloading the code for such a framework or inspecting their site with developer tools open to see how they achieve certain layouts.

I hope this information proves helpful.

Answer №3

To customize the size or position of text without interfering with other content, you can use a similar approach like this:


#banner {
  background-color: #ff9900;
  color: black;
  text-align: center;
  padding: 10px;
  border: 5px solid;
  border-radius: 15px;
  position: relative;
}

#banner h1 {
  position: absolute;
  top: 20px;
  left: 50px;
}

Answer №4

To ensure proper alignment without taking up unnecessary space, you can include the following CSS code:

#border {
  position: absolute;
  bottom: 20px;
  left: 20px;
}

Additionally, make sure to add position: relative to the surrounding element:

#header {
  position: relative;
}

By implementing these changes, you can center-align your header element seamlessly.

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

How to place a button in SwiperJs using React

Can anyone provide guidance on how to position the navigation buttons in a manner similar to the image below? The desired layout is for the buttons to appear on the outer edges of the swiper component. You can refer to this demo for more information. htt ...

What is the best way to symbolize a breadcrumb offspring?

In my table representation, the breadcrumb is shown as: <ol class="breadcrumb" data-sly-use.breadcrumb="myModel.js"> <output data-sly-unwrap data-sly-list="${breadcrumb}"> <li itemscope itemtype="http://data-vocabulary.org/ ...

Enhancing JSON Objects in AngularJS with Custom Properties and Calculations

Hello, I'm still getting the hang of angularjs and could use some guidance. I have a Rest service that provides data on saleItems when a get request is made, as shown below: saleItems = [ { "id": 236, "variant": "Oval Holder", "mrp": "6 ...

What is the best way to add bold formatting to text enclosed in parentheses using javascript/jquery?

How can I use jQuery or JavaScript to make the text inside parentheses bold? For example: "what is your Age (in Year)." I need assistance in making the text within parentheses bold using either jQuery or JavaScript. Can someone help me with this task? ...

List items not appearing inline

I'm having an issue with displaying a list of movies from my database. Instead of showing inline as intended, they are appearing vertically. I've tried using both inline-block and inline for the li elements, but so far nothing has worked. Any ass ...

Why does the appearance of my PHP spreadsheet change when I attempt to print it?

After using a CSS stylesheet to position my textboxes correctly, I noticed that in Chrome everything appeared fine. However, when attempting to print the site (Ctrl+P), each sentence and textbox shifted. How can I ensure they remain in place? <!-- #cap ...

Utilizing Bootstrap 3: Mastering the Implementation of .col Classes with .form-control Classes

In my form, I have utilized the .form-control classes for the form elements. To arrange two inputs side by side, I am applying .col-md-6 on each of these inputs. However, the width generated by .col-md-6 is being overridden by the .form-control class. Is ...

Angular2 poses a strange problem with ngClass

It seems like Angular is expecting me to use single quotes for the class names even if there are no hyphens in my CSS class name. I've tried everything but Angular keeps insisting on using hyphens for this specific CSS class... it's strange, or m ...

Adjust Text to Perfectly Fit Button

I am developing a quiz using bootstrap and javascript. One issue I encountered is that the text in the buttons can sometimes be longer than the button itself. This results in the text not fitting properly within the button, making it unreadable on mobile ...

include a button next to the input field

As you reduce the browser window size, you may notice a different layout designed specifically for iPhone. One question that arises is how to add a button next to the search text box dynamically using JavaScript. The issue at hand is that the text box is b ...

Using CSS styling to dictate how browsers display web content, specifically through setting font size measurements in EM

On different mobile devices and various browsers such as Internet Explorer and Mozilla, the font size in some divs does not appear consistent. Specifically, on a Samsung Galaxy S6. I am using EM units: I know it may not be ideal but I prefer this method a ...

Issue encountered when attempting to connect an external script to a Vue single file component

Struggling to link an external script to a single file component in Vue. My project setup is as follows: https://i.sstatic.net/LWvNx.png I need to link the file components/Sshy to ../javascripts/ I have successfully linked other scripts using either of ...

CSS: Placing a Column below a Float Positioned Column

While performing some maintenance on a website, I noticed that one page is not displaying correctly. There is a container div for a column on the left and a container div for content on the right, both within an overall page content container. Below these, ...

What happens if I define both the left and right properties for spans?

This is a class for span with the CSS properties position:absolute; top:0px; left:0px; right:0px; .textStyle1 { font-size:24px; font-family:'Arial'; position:absolute; top:0px; left:0px; right:0px; } #div1 { position:absolute; lef ...

What is the best way to showcase Json API content on an HTML page?

I possess a strong proficiency in html and css, however I lack experience in utilizing javascript. My aim is to showcase the date received from an API onto an html page Despite several attempts, I have not been able to achieve success yet. var getJSON ...

Determine the outcome with a PHP conditional statement for either "

I'm currently working on adding a function to a script where the user is prompted for a code, which I have successfully added. However, I am facing an issue in determining when to ask the user for the code and when not to. So, I believe I need to use ...

Modifying Bootstrap image dimensions

I've been working on creating a card div with two images inside: an up arrow and a down arrow. Everything looks good when the page is in full screen mode, with the images displaying at their full size. However, with Bootstrap's responsive design ...

Formulate a jQuery array consisting of droppable components

I have successfully implemented draggable li-elements and droppable boxes using jQuery UI. Here is my structure: A list of 3 different permission types <ul> <li data-action="create">Create</li> <li data-action="edit">Edi ...

Retrieve information from an external JSON file and present it in a table format - Obtain the most recent data available

I am attempting to extract the data from On the website, there is a dropdown menu that displays two different screenshots. I want to modify my code so that it shows the most recent screenshot data in a table. Here is my current code: http://jsfiddle.net ...

Modify vanilla JavaScript carousel for compatibility with Internet Explorer

I am currently in the process of creating a website that incorporates a carousel similar to the one found at the following link: https://codepen.io/queflojera/pen/RwwLbEY?editors=1010 At the moment, the carousel functions smoothly on opera, chrome, edge ...