By Zara Z. Zingpocket | Created on 2025-06-28 13:55:25
You've got a problem that needs solving. We're here to help.
Problem: Floating Elements Not Centering
Invalid4564 has been trying to get their floating elements to center, but it's not working. They've specified widths for each element, but the container (body) doesn't have a width defined, so it spans the entire browser viewport.
Solution: Define Container Width
Vragabond points out that the three main areas with floats need to be in another container and its width needs to be defined. This will prevent the elements from stacking when the viewport is resized.
Additionally, there's no such value as 'center' for the float property. It's ignored.
Example Solution:
```css
.container {
width: 800px;
margin: 0 auto;
}
header, #navigation, #links {
float: left;
}
```
This will create a container with a defined width and center it horizontally. The three main areas can then be floated within this container.
Thanks!
Feherke reminds us to thank our helpful users by clicking the star at the bottom of their post.
Similar Threads:
- Background image with overlay which Hover when over a specific Area/Form
- From HTML Page open an MDB files on the server and work
- Body of email not appearing in correct font on iPhone and iPad
Share This Thread!
Facebook
X (Twitter)
Reddit
Pinterest
Tumblr
WhatsApp
Email
Sources:- [
how do i keep sections from moving when i minimize window?] (
https://www.tek-tips.com/threads/how-do-i-keep-sections-from-moving-when-i-minimize-window.1611893/)
- [
VBscript and Javascript in the same HTA Application not working...] (
https://www.tek-tips.com/threads/vbscript-and-javascript-in-the-same-hta-application-not-working.1437650/)
- [
GetFileAttributes - Interpretation of returned value | Tek-Tips] (
https://www.tek-tips.com/threads/getfileattributes-interpretation-of-returned-value.255489/)
- [
Browse Folder Control in vb6? | Tek-Tips] (
https://www.tek-tips.com/threads/browse-folder-control-in-vb6.573084/)
- [
How do I calculate a Checksum? - Visual Basic (Classic)] (
https://www.tek-tips.com/threads/how-do-i-calculate-a-checksum.1391039/)
- [
Calculating gear ratios in Excel - Microsoft: Office | Tek-Tips] (
https://www.tek-tips.com/threads/calculating-gear-ratios-in-excel.1707812/)
- [
How to Trace an in coming call | Tek-Tips] (
https://www.tek-tips.com/threads/how-to-trace-an-in-coming-call.1587036/)
- [
Large Amount of Page Faults - IBM: AIX | Tek-Tips] (
https://www.tek-tips.com/threads/large-amount-of-page-faults.1117299/)
- [
Query a Registry Key - VBA Visual Basic for Applications (Microsoft)] (
https://www.tek-tips.com/threads/query-a-registry-key.860209/)
- [
perl on redhat 9 | Tek-Tips] (
https://www.tek-tips.com/threads/perl-on-redhat-9.915579/)