Home Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
April 18, 2024 - @256.09 (what is this?)
Forum activity rating: Four Star Posts: 52/1k.beats Unread Topics | Unread Replies | Own Posts | Own Topics | Random Topic | Recent Posts
News: :4u: ~~~~~~~~~~~  :4u:

+  MelonLand Forum
|-+  World Wild Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  HELP: html/css box float


« previous next »
Pages: [1] Print
Author Topic: HELP: html/css box float  (Read 482 times)
muddywater
Newbie
*


its me brian


View Profile

First 1000 Members!Joined 2023!
« on: February 08, 2023 @978.72 »

I'm currently having trouble with boxes on my neocities site...

I want to put two things next to each other within a box, but when I use "float" the things move out of the box.

my code looks like this (things in box)

Code
<body>

 



 <div class="container"> <center> <p> top bar </p> </center> </div> 

 

 <div class="x">

 

 

 <img src="rammy1.jpeg"><img src="spin.gif">

 



 </div> 

 
[color=#ff4cc6][color=#000000] </body>

.container{
[/color][/color]
 border:1px solid black;

 background-color:red; 

}



 .x {

 margin: auto;

 width: 50%;

 border: 3px solid green;

 padding: 10px;

}





.top {

padding: 10px;

}



.bar { 

 float:left;

}


and like this (things outside box)
Code
 <body>
 
 
 <div class="container"> <center> <p> top bar </p> </center> </div> 
 
 <div class="x">
 
 <div class="bar">
 
 <img src="rammy1.jpeg"><img src="spin.gif">
 

 </div> 
 </div> 
 
 
 </body>

(css is the same)
any help? also i know this might look confusing im free to clarify lol :ohdear::ohdear:
« Last Edit: February 08, 2023 @982.51 by muddywater » Logged

Melooon
Hero Member ⚓︎
*****


So many stars!

SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games

View Profile WWW

First 1000 Members!spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!The Smallest Ozwomp Known To ManBug!
« Reply #1 on: February 09, 2023 @42.21 »

Errr its a little hard to tell what exactly your code is trying to do.. but it sounds like this would be (mostly) a solution for you.

Code
<html>
 <head>
  <style>
   .center {
    text-align: center;
   }
   
   .boxes {
    display: flex;
   }
   
   .boxes div {
    width: 100px;
    height: 100px;
    background-color: red;
    margin: 10px;
   }
  </style>
 </head>
 <body>
  <div class="container">
   <p class="center">top bar</p>
   <div class="boxes">
    <div>Box A</div>
    <div>Box B</div>
   </div>
   <img src="rammy1.jpeg"><img src="spin.gif">
  </div> 
 </body>
</html>

So here I have created 2 boxes that are side by side and are totally equal - you have your centred text above them, and your two images below them.

I converted your <center> tags into CSS becouse thats just a good idea! BUT the important thing you need to look at is the display: flex; thats the thing making your box goes next to each other - then the .boxes div is styling the boxes and giving them a set size!

Not sure if thats exactly what your asking for - but its gotta be a good start :grin:
« Last Edit: February 09, 2023 @44.44 by Melooon » Logged


everything lost will be recovered, when you drift into the arms of the undiscovered
RodFireProductions
Jr. Member ⚓︎
**


🍄🖤🐀

StatusCafe: rodfire8181
iMood: rodfire8181
Itch.io: My Games

View Profile WWW

First 1000 Members!Joined 2022!
« Reply #2 on: February 09, 2023 @624.50 »

Another way to handle this that gives you a bit more control than flex is by using grids. Also I remember trying to use float when I was just starting out and it was horrible. I don't use it anymore.

Code
.container {
  display: grid;
  grid-template-columns: 1fr 1fr; /* You can alter these sizes all you'd like */
  grid-template-rows: 1fr; /* or auto */
}

Code
<div class="container">
  <div>Column 1</div>
  <div>Column 2</div>
</div>

I hope this helps.
Logged

we art, web dev, and game dev
muddywater
Newbie
*


its me brian


View Profile

First 1000 Members!Joined 2023!
« Reply #3 on: February 10, 2023 @751.00 »

TYSMMMM!!! this helped :transport:
Logged

Pages: [1] Print 
« previous next »
 

Vaguely similar topics! (3)

What helped you code html/css easy?

Started by LIABoard ✁ ∙ Web Crafting

Replies: 17
Views: 1283
Last post October 11, 2023 @152.56
by lars
Help: Making bubble-like boxes with css?

Started by rinniBoard ☔︎ ∙ I need Help!

Replies: 6
Views: 387
Last post August 19, 2023 @154.34
by rinni
Weird boxes your family has kept..,

Started by WynnDawnstriderBoard ☺︎ ∙ General Interests

Replies: 0
Views: 179
Last post December 20, 2023 @693.53
by WynnDawnstrider

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies Forum Guide | Rules | RSS | WAP2


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi