Home Events! Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
November 21, 2024 - @571.90 (what is this?)
Forum activity rating: Three Stars Posts: 38/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts    Start New Topic
News: :4u: :transport: More is More :transport: :4u:

+  MelonLand Forum
|-+  World Wild Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  how to taper a div/flexbox?


« previous next »
Pages: [1] Print
Author Topic: how to taper a div/flexbox?  (Read 358 times)
candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« on: August 06, 2024 @54.55 »

hi!

how would you go about making a div tapered on one side? preferably something that works with a flexbox but im not sure where to start with this

example:


* clipboard.png (11.39 kB, 512x512 - viewed 11 times.)
Logged

new to oldnet be nice




xixxii
Full Member ⚓︎
***


they/them

⛺︎ My Room

View Profile WWW

Web 1.0 Picture Size Expertthe xixxiiJoined 2024!
« Reply #1 on: August 06, 2024 @60.00 »

Logged

candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #2 on: August 06, 2024 @69.83 »

you can use borders to do that! w3schools has a section for making different shapes with css here!  :wizard:

thanks, but its not working properly at all.. it seems to only taper the actual border part, instead of the full height of the box


* clipboard.png (24.4 kB, 165x73 - viewed 11 times.)
Logged

new to oldnet be nice




xixxii
Full Member ⚓︎
***


they/them

⛺︎ My Room

View Profile WWW

Web 1.0 Picture Size Expertthe xixxiiJoined 2024!
« Reply #3 on: August 06, 2024 @126.38 »

thanks, but its not working properly at all.. it seems to only taper the actual border part, instead of the full height of the box


could you post the code you used? it's hard to figure out what needs to be fixed just based on a picture!
Logged

candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #4 on: August 06, 2024 @128.32 »

could you post the code you used? it's hard to figure out what needs to be fixed just based on a picture!

Code
border-bottom: 5px solid red
border-right: 20px solid transparent
Logged

new to oldnet be nice




xixxii
Full Member ⚓︎
***


they/them

⛺︎ My Room

View Profile WWW

Web 1.0 Picture Size Expertthe xixxiiJoined 2024!
« Reply #5 on: August 06, 2024 @143.95 »

Code
border-bottom: 5px solid red
border-right: 20px solid transparent

my guess is that you misunderstood how the code works? taking their trapezoid as an example;

Code
.trapezoid {
	border-bottom: 50px solid #555;
	border-left: 25px solid transparent;
	border-right: 25px solid transparent;
	height: 0;
	width: 125px;
}

the shape you see is made entirely of borders; that's why the height is 0! the 50 pixel tall bottom border makes up the body of the shape, and the transparent left and right borders are creating slices in that bottom border. the trapezoid shape comes from the corners where the (invisible) left and right borders meet the bottom border! if you change the color from "transparent" to "green" (or any other color), that might help it make more sense how it's working.
if you want your tapered div to have a black background and a red outline, that's more complicated and will require a different method i think!
Logged

candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #6 on: August 06, 2024 @144.76 »

my guess is that you misunderstood how the code works? taking their trapezoid as an example;

Code
.trapezoid {
	border-bottom: 50px solid #555;
	border-left: 25px solid transparent;
	border-right: 25px solid transparent;
	height: 0;
	width: 125px;
}

the shape you see is made entirely of borders; that's why the height is 0! the 50 pixel tall bottom border makes up the body of the shape, and the transparent left and right borders are creating slices in that bottom border. the trapezoid shape comes from the corners where the (invisible) left and right borders meet the bottom border! if you change the color from "transparent" to "green" (or any other color), that might help it make more sense how it's working.
if you want your tapered div to have a black background and a red outline, that's more complicated and will require a different method i think!

oh :( any idea how to do it in a different method then? sorry
Logged

new to oldnet be nice




xixxii
Full Member ⚓︎
***


they/them

⛺︎ My Room

View Profile WWW

Web 1.0 Picture Size Expertthe xixxiiJoined 2024!
« Reply #7 on: August 06, 2024 @155.73 »

oh :( any idea how to do it in a different method then? sorry

you could use an image background or an svg polygon, or layer the black div on top of a red div that's the same shape but bigger maybe... maybe something with clip-path would work, since it seems like that's similar to making an svg, but i've never used it before so i'm not sure i really get it or how it's different from svgs. :dunno:
Logged

candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #8 on: August 06, 2024 @209.40 »

update: I have gotten things even worse and more messy please help please i dont understand this at all and i am tired

thank god for git

heres the current code:
Code
  1 <div id="player">
  2     <div>
  3         <div id="player-inner">
  4             <span id="player-text"></span>
  5             <a href="javascript:void(0)" onClick="stopPlayer()">stop</a>
  6             <a href="javascript:void(0)" onClick="MIDIjs.play('/assets/mid/c
    anyon.mid')">play</a>
  7         </div>
  8         <img src="/assets/images/decor/taper.png">
  9     </div>
 10 </div>
Code
79 #player {
 80     position: fixed;
 81     bottom: 8vh; left: 4vw;
 82     padding: 10px;
 83     gap: 10px;
 84     width: 25vw;
 85
 86     transform: rotate(3deg);
 87     z-index: 5;
 88 }
 89
 90 #player-inner {
 91     background-color: black;
 92     border-bottom: 5px solid red;
 93 }
 94
 95 #player * {
 96     color: white;
 97     text-decoration: none;
 98 }
 99
100 #player div {
101     display: flex;
102     justify-content: flex-end;
103     overflow: auto;
104
105 }
106
107 #player img {
108     float: right;
109     display: absolute;
110     right: 0;
111     text-align: right;
112 }


* clipboard.png (43.6 kB, 209x104 - viewed 13 times.)
Logged

new to oldnet be nice




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 #9 on: August 06, 2024 @536.10 »

Ooph ~ I decided to finally figure this one out since Iv never actually known how to do this  :omg:

So this might not be a perfect soloution; but it does work and I think you can modify it to fit most needs!

HTML is a simple DIV with some text in it:
Code
<div class="taper">HELLO</div>

CSS ~ use use the ::after selector to add an empty virtual triangle made using the method @xixxii suggested, and then we position it 100px to the right of the origonal div ~ the result is a tapered div! You'd need to modify the offsets and sizes to suit your content, but that should be pretty simple! (this does not allow for resizing divs, but maybe you can figure that out and post about it here!  :unite: )
Code
.taper {
  background-color: red;
  width: 100px;
  height: 50px;
  position: relative;
}

.taper::after {
  content: '';
  border-style: solid;
  border-width: 50px 0 0 50px;
  border-color: transparent transparent transparent red;
  position: absolute;
  top: 0;
  left: 100px;
}
« Last Edit: August 06, 2024 @539.81 by Melooon » Logged


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


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #10 on: August 06, 2024 @581.05 »

Ooph ~ I decided to finally figure this one out since Iv never actually known how to do this  :omg:

So this might not be a perfect soloution; but it does work and I think you can modify it to fit most needs!

HTML is a simple DIV with some text in it:
Code
<div class="taper">HELLO</div>

CSS ~ use use the ::after selector to add an empty virtual triangle made using the method @xixxii suggested, and then we position it 100px to the right of the origonal div ~ the result is a tapered div! You'd need to modify the offsets and sizes to suit your content, but that should be pretty simple! (this does not allow for resizing divs, but maybe you can figure that out and post about it here!  :unite: )
Code
.taper {
  background-color: red;
  width: 100px;
  height: 50px;
  position: relative;
}

.taper::after {
  content: '';
  border-style: solid;
  border-width: 50px 0 0 50px;
  border-color: transparent transparent transparent red;
  position: absolute;
  top: 0;
  left: 100px;
}

t thx! i uh didnt realize you could set the position to absolute

also i changed it to right: -40px


* clipboard.png (51.9 kB, 272x101 - viewed 9 times.)
Logged

new to oldnet be nice




Pages: [1] Print 
« previous next »
 

Vaguely similar topics! (2)


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