Home Events! Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
November 22, 2024 - @523.04 (what is this?)
Forum activity rating: Three Stars Posts: 35/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts    Start New Topic
News: :happy: Open the all windows! Your mind needs storms and air! :happy:

+  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 756 times)
muddywater
Newbie
*


its me brian

⛺︎ My Room

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!

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

View Profile WWW

Thanks for being rad!a puppy for your travelsAlways My PalFirst 1000 Members!spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!...
« 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 ⚓︎
**


🍄🖤🐀

⛺︎ My Room
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

⛺︎ My Room

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)

Melons critiquing and helping each other

Started by urgellxBoard ✎ ∙ Art Crafting

Replies: 22
Views: 1913
Last post August 24, 2024 @487.13
by e-
Weird boxes your family has kept..,

Started by WynnDawnstriderBoard ☺︎ ∙ General Interests

Replies: 0
Views: 427
Last post December 20, 2023 @693.53
by WynnDawnstrider
Chat boxes?

Started by onedearBoard ✁ ∙ Web Crafting

Replies: 3
Views: 881
Last post May 01, 2024 @984.61
by zzzzz

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


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