Stacking issue - elements not properly aligned

Is there a way to move my H1 text below the blue category button instead of beside it? Thank you in advance!

http://jsfiddle.net/TDBzN/

<div id="article" class="animated2 fadeInLeftBig">
<div class="article-close"></div>
    <div class="category">#Category</div>
    <h1>This is the H1</h1>
    <p class="intro">Lorem ips um dolor sit amet, consectetur adipiscing elit. Nam sit amet diam nisl. Aliquam quis est eu elit facilisis aliquam. Pellentesque porta nunc diam <a class="various" href="#">Inline</a></p>
</div>

CSS:

#article {
    /* opacity controlled via fadeInLeftBig */
    position: absolute;
    width: 600px;
    left: 230px;
    top: 0;
    height:100%;
    background-color: #fff;
    opacity:0.9;
    padding: 30px 50px 50px 50px;
    z-index: 1000;
    box-shadow:-2px 0 5px 0 rgba(0, 0, 0, 0.5); 
}
#article .intro{
    font-family: 'Open Sans', sans-serif;
    font-weight:600;
    }

#article h1 {
    font-size: 33px;
    color:#555;
    font-style:italic;
}
#article h2 {
    color:#555;
    margin-bottom:5px;
}
#article p {
    font-style: normal;
    font-weight: 300;
    /* color: #555; */
    color: #555;
    font-size: 15px;
    line-height: 22px;
    padding: 10px 0;
    margin-top: -10px;
    text-align:justify;

    }
#article a {
    color: #F15034;
    text-decoration: none;
    font-weight: bold;
}
#article a:hover {
    border-bottom: 2px solid #F15034;
}

.category {
    float: left;
    text-align: center;
    font-size: 12px;
    color: white;
    padding: 8px 18px;
    margin: 18px 0 0 0px;
    text-decoration: none;
    -webkit-transition: background 0.3s ease;
    -moz-transition: background 0.3s ease;
    -ms-transition: background 0.3s ease;
    -o-transition: background 0.3s ease;
    transition: background 0.3s ease;
    background: rgba(71, 186, 255, 0.8);
}

Answer №1

It is recommended to add clear: both; to the h1 tag. Another option would be to include a separate clear:both; <div>, although it is not necessary in this case.

DEMO: http://jsfiddle.net/TDBzN/6/;

h1 
{
    clear:both;
}

To insert a clear:both; div, place it between the h1 element and the floated element, such as .category.

<div style="clear: both;"></div>

This method is useful for adding a clearing element only where needed, without directly affecting the element itself.

Answer №2

Make sure to add clear:left to your heading for proper alignment

#article h1 {
    font-size: 33px;
    color:#555;
    font-style:italic;
    clear:left;
}

For a visual example, visit http://jsfiddle.net/TDBzN/2/

Answer №3

VIEW DEMO

Make changes to the .category class as follows:

.category {
float: left;  /* REMOVE */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}

Change it to:

.category {
max-width:70px; /* EDITED */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}

These adjustments should work perfectly.

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

Launch the game within the gaming application

I am looking to incorporate a game within another game... Here's what I mean: Open the app: Pandachii Next, navigate to the 4th button (game pad). When we click on the game icon, I want to launch another game (located below the Pandachii window - c ...

Solving the problem of Hover Effects in CSS

I am struggling to get the nav-link to be blue in color with a dark-blue hover effect. I managed to set the color correctly, but for some reason, the hover effect is not working. Can anyone help me figure out what the issue might be? Additionally, does any ...

Real-time preview of a text field in JavaScript

I'm attempting to create a similar piece of code like the one at the bottom of this page for leaving comments. I have the basic code, but the result doesn't display new lines (or HTML, although that's not essential). I have the function belo ...

Angular 6 seems to be having issues loading Bootstrap

I've run into an issue while trying to incorporate Bootstrap into Angular 6. I have already installed Bootstrap using npm install bootstrap and added it to angular.json, but it's still not functioning. Is there something else I should be doing? A ...

Alter the color of the initially chosen option in the dropdown selection

I'm struggling to modify the color of the initial selection while keeping the remaining selection-options at their default black color. Unfortunately, I haven't been successful in achieving this. Currently, all colors are #ccc. What I want is fo ...

Footer displaying page numbering

I recently installed dompdf 0.83 and have been able to generate documents successfully. However, I am struggling to create a footer that displays the page number out of the total number of pages. Both css and script methods have not been effective for me s ...

Is there a way to seamlessly transition between images in a slider every 3 seconds using javascript?

<!DOCTYPE html> <html> <head> <title>Hello</title> <meta http-equiv="Content-Type" type="text/html" charset="UTF-8"/> <style> *{margin:0; padding:0;} .mySlides{ position:relative; width:1000px; ...

How do I change the alignment of X axis labels in an Asp.net chart to be left-aligned instead of centered?

I've been struggling for hours trying to figure out this simple issue. I am working on creating a histogram using the asp chart control. My main problem is that I can't seem to get the x-axis label to appear on the left side of each column instea ...

Guide on changing the CSS of MUI parent components to set the display of buttons to 'block' in React

I'm facing a challenge with my modal design for mobile view. I need the buttons to display in a stacked format, one above the other, taking up the full width of the modal. I've been exploring ways to override the existing CSS within the component ...

Aligning the column to the right to ensure the text is centered horizontally on the screen

<div className={css.title} > <div className={css.row}> <div className={css.columnLeft}> <div className={css.header}>Images</div> </div> <div className={css.col ...

Can applications on Windows 8 operate using JavaScript, HTML5, and CSS3 that adhere to industry standards?

As a .NET developer, I tuned in to the keynote for the Build Event in Anaheim, California and had some questions regarding the new support for creating Windows 8 applications using JavaScript, HTML5, and CSS3. They showcased several examples and mentioned ...

Experience the seamless transition of new CSS animations

I designed a basic HTML game where a moving box disappears when clicked on. However, the animation that follows does not originate from the click location but rather from the original position. I believe the remove @keyframes at 0% should be based on the ...

PHP code in Wordpress incorporating an Ajax request

Does anyone know how to fetch user data as a string using ajax in WordPress? I think I understand the basic concept PHP This code goes in my functions.php file add_action('template_redirect', 'edit_user_concept'); function edit ...

SQL - Extracting Information from HTML in a Column

I have a column named "Content". Within this column, there is HTML code containing various data. My task is to extract specific information from this HTML code and split it into five different columns: "Name", "Surname", "Email", "Telephone", and "Message" ...

Ways to extract specific HTML from a jQuery element

When fetching html from a website, how can I extract specific html content instead of getting all of it? I have attempted the following method: Before appending data to the target below container.html(data); I would like to perform something like data.f ...

applying a margin to the cover div

I am currently working on a #cover element with the following CSS styling: #cover { background-color: #FFFFFF; height: 100%; opacity: 0.4; position: fixed; width: 100%; z-index: 9000; } The goal is to have it cover the entire visi ...

Incorporating PlayN games into an HTML/JS application

I've been considering creating a game using PlayN. While it's great for the game itself, I would rather handle menus, navigation, high-score lists, etc in HTML (possibly with GWT). If I develop a game using PlayN, are there ways to integrate it ...

Ways to resolve the issue of being unable to retrieve data using jQuery

My code is working, but I am facing a little annoying problem that I can't solve on my own. The problem is that I can only retrieve the first record (id) from my data grid, but I can't retrieve the second or any other record id. For example: W ...

Issue: TypeError: Unable to access the 'getBoundingClientRect' property of an undefined value

Is there anyone who can lend me a hand? I encountered an issue: TypeError: Cannot read property 'getBoundingClientRect' of null https://i.stack.imgur.com/Jnfox.png Here is the code snippet I am trying to render: <div className="box&qu ...

Guide to displaying names in PHP/HTML organized by group or rank

I am in the process of setting up a NASCAR league for my family members and I am currently developing a roster page where they can easily add or remove drivers. How can I display the drivers according to their rank as stored in the database? (A/B/C/D/E gro ...