Place the logo in the center both vertically and horizontally

I need help centering the logo and text on my website. I want them to be perfectly centered both vertically and horizontally.

After trying a few different things, this is the HTML code I have come up with:

<html>
<head>
<title>XXX</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
    margin:50px 0px; padding:0px; /* Ensuring consistency across browsers */
    text-align:center; /* Fix for IE5/Win */
    }
#floater    {float:left; height:50%; margin-bottom:-120px;}

#Content {
    clear:both; 
    width:500px;
    margin:0px auto; /* Centering the content */
    text-align:center; /* Counteract to IE5/Win fix */
    padding:15px;

    height:240px; 
    position:relative;
    }
#text-center{
    text-align:center;
    font-family:Tahoma, Geneva, sans-serif
    }
</style>
</head>
<body>

<div id="Content">
<img src="logo_small.jpg" width="400" height="143">
<p id="text-center">Coming soon</p>
<p id="text-center">more text</a></p>
</div>

</body>
</html>

I am not very familiar with HTML/CSS and would appreciate any guidance on how to achieve the desired centering effect.

Answer №1

My solution can be found here: http://jsfiddle.net/CMfEH/

I implemented a modified version of the technique outlined in Vertically Centering in CSS.

Answer №2

It is not recommended to vertically align content, however, it can be achieved by making some adjustments to the CSS code:

#Content {
        margin: 0px auto;
        ...
        height: 100%;
        }
#subContent {
        position: absolute;
        top: 50%;
        height:240px; 
        margin-top: -120px;
        }

You can also create a <div id="subContent"> inside your Content parent 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

I am looking to keep the form information stored in a div to ensure it remains on the page even after refreshing

I have a form data that is transformed into PHP and styled with CSS. I want to save this form so it can be viewed by everyone on a page. When the page is refreshed, I want the div containing the form information to remain visible. <form name = "quoted" ...

Remove newline character from HTML code using Python 3.2 and urllib module

After fetching HTML content as a string using urllib, I encountered difficulty in searching the string due to its HTML format. Is there any way to "unformat" the string by removing all the new lines without altering the HTML code itself? Here is the Pytho ...

Displaying data retrieved from Angular by clicking a dropdown button

Struggling with a minor issue while using Angular on the frontend and .NET Core on the backend? Look no further, I have created a video demonstration below to help you out. Despite spending countless hours trying to solve the problem, it still persists. T ...

Looking to substitute the browse button with an input tag when uploading a file in PHP?

I'm just starting out in PHP programming and currently working on a user profile that involves allowing users to upload their profile picture. Here's the code I've written: <?php echo form_open_multipart('','class="form-ho ...

When hovering over an object in three.js, the cursor should change on mouseover

In my scene, I have added a sphere and plane geometry. Clicking on the plane geometry will open a linked website. Now, when hovering over the plane geometry, I want the mouse cursor to change to a hand pointer icon, and revert back to its original style ...

Combining multiple images into one CSS image sprite to create 4 clickable

Could someone please review this segment of the CSS to ensure its accuracy? CSS #nav-list { list-style-type: none; background-repeat: no-repeat; background-image:url("../_img/Footersprite.png") } #nav-list li, #nav-footer a { height: 40 ...

Collapse the accordion by sliding it back to the top position

I have successfully implemented the Flexible Slide-to-top Accordion on my webpage. Initially, I struggled with the functionality to have only one accordion open at a time due to my limited knowledge of jQuery. However, after overcoming this challenge, I n ...

I am interested in creating some CSS styles to modify the color of a toggle switch's plus sign icon

Can anyone help me customize my Wordpress theme? I'm trying to change the color of my toggle plus signs to white using CSS, but I can't figure it out. Your assistance would be greatly appreciated. Here is the URL: This is the CSS code I attempt ...

Is there a way to capture and prevent the onMouseWheel event from being processed in other parts of the code

Is there a way to capture the onMouseWheel event for the entire page? I am working on custom scrolling and need to prevent other elements on the page from handling this event. Any suggestions on how to achieve this? Appreciate your help in advance. ...

Center the content of the page by adjusting the graphical source with HTML and CSS (SCSS) to align perfectly in the middle

I am having trouble aligning the images in the center of the page without using fixed values for margins. Despite trying various pieces of code, I still cannot achieve the desired outcome. Below is the code snippet I have been working on: .row_of_servic ...

The method for implementing conditional CSS on an element and ensuring it remains in place

I'm looking to add a style to an element with either angular or jquery, but I've noticed that the style gets lost when I change views. Would it be best to use $window and local.storage for this purpose, or are there simpler methods available? ...

Having trouble activating the Tailwind CSS or Intellisense features

I'm having trouble getting my React app to properly style divs using Tailwind CSS. The intellisense feature doesn't suggest any styling options for me either. import './App.css'; function App() { return ( <div className="t ...

Having difficulty identifying a consistent sequence within a string through regular expression matching

Looking to extract valid hexadecimal color values from CSS code. Rules for HEX Color Code Must start with a '#' symbol. Can have either 3 or 6 digits. Digits must be in the range of 0-F or 0-f. Example input: #BED { color: #FfFdF8; backgro ...

Create a box with borders and divisions using HTML

Hello, I am trying to create a box in HTML with a slanted divider line inside. How can I achieve this design? I am aiming to replicate the layout shown in this image: Link to Image I have tried implementing the code below, but the alignment is not matchi ...

Stacking Bootstrap rows one on top of the other

Currently, I am working on enhancing my frontend CSS skills by experimenting with creating two overlapping Bootstrap rows while maintaining their responsive grid-like behavior. This concept is completely new to me and I'm unsure of how to approach it. ...

Is there a way to modify the background color of a button once it has been clicked, specifically using JavaScript?

I am looking to change the background color of a button that I have clicked on in my code. Do I need to use loops and conditions for this task? I attempted to access the first index, but I am unsure how to change the background color of other buttons. l ...

Display the input text on the page and output it as well

Is it possible to have a text input on a website where users can type text and have it immediately display on the page, similar to Twitter? I am aware of alert windows and prompt windows but I am looking for something different. I hope this can be achieve ...

How can I emphasize the React Material UI TextField "Cell" within a React Material UI Table?

Currently, I am working on a project using React Material UI along with TypeScript. In one part of the application, there is a Material UI Table that includes a column of Material TextFields in each row. The goal is to highlight the entire table cell when ...

An easy CSS conundrum when hovering

Looking for some assistance with CSS. I want to display the text "Featured Page" with a picture appearing on the right side upon hovering (mouseover). Currently, the picture shows up under the text using the following CSS, but I need it to be larger and pl ...

Pedestrian crossing Cordova experiences delayed response despite ontouchstart attempts to fix it

I have been experiencing a delay issue when using a CSS button with the ":active" pseudo-class on my phone. Every time I click the buttons, there is a noticeable delay before entering the active phase. Here is my CSS code: .btn {...} .btn:active{...} To ...