Am I Good Enough To Solve These CSS Battles?

Web Dev Simplified
24 Aug 202428:25

Summary

TLDRIn this instructional video, Kyle from Web Dev Simplified demonstrates his approach to solving complex CSS challenges live. He tackles a Deadpool-themed CSS battle, detailing his thought process from analyzing components to coding and debugging. Kyle discusses strategies for creating shapes like circles and rectangles, using properties like border-radius and transform: skew. He emphasizes learning from the process, applying these skills to real-world projects, and offers a CSS course for further learning.

Takeaways

  • 🎨 The video demonstrates a live approach to solving complex CSS challenges, showcasing the thought process behind tackling unseen problems.
  • 🔍 The presenter, Kyle, emphasizes the importance of understanding how different components of a design work together.
  • 📐 Kyle discusses two methods for creating a black circle with a segment missing: one big circle with a red strip or two separate semi-circles.
  • 🖥️ The video provides a practical example of coding and debugging live, offering insights into problem-solving in web development.
  • 🌈 Kyle simplifies the Deadpool CSS battle by breaking down the design into manageable components like background, red section, and black circles.
  • 🛠️ Debugging techniques are highlighted as Kyle adjusts positioning and sizing to match the target design.
  • 👁️ For the eyes, Kyle decides on creating perfect half-circles and positions them accurately within the black circle.
  • 🔄 Kyle experiments with different CSS properties like `border-radius` and `transform` to achieve the desired shapes and positions.
  • 💯 The video concludes with a focus on achieving a high accuracy score in the CSS battle, reflecting a real-world approach to web design.
  • 📚 Kyle promotes his CSS simplified course, which aims to build a strong foundation in CSS, making it easier to tackle complex coding challenges.

Q & A

  • What is the main focus of the video?

    -The main focus of the video is to demonstrate the presenter's thought process and approach to solving complex CSS challenges, specifically 'CSS battles', which are new and unattempted before.

  • Who is the presenter of the video?

    -The presenter of the video is Kyle, who works to simplify web development for viewers so they can build their dream projects.

  • What is the Deadpool CSS battle that Kyle starts with?

    -The Deadpool CSS battle involves recreating a design with Deadpool and Wolverine, inspired by the movie 'Deadpool Wolverine'.

  • How does Kyle approach the design of the black circle in the Deadpool CSS battle?

    -Kyle considers two approaches for the black circle: creating one large circle and adding a red strip in the middle, or creating two separate circles and cutting them in half. He experiments with both to determine the best approach.

  • What is the strategy for positioning the eyes in the Deadpool design?

    -Kyle decides to create perfectly cut in half circles for the eyes and positions them using top and left values, adjusting their size and rotation to match the design.

  • How does Kyle ensure the elements are centered in the design?

    -Kyle uses a combination of flexbox properties, absolute positioning, and transform properties to ensure elements like the black circle and eyes are correctly centered.

  • What is the significance of the red band in the Deadpool design?

    -The red band is a central element that runs vertically down the middle of the black circle, separating it and adding a distinctive feature to the Deadpool mask design.

  • How does Kyle handle the scoring system in CSS battles?

    -Kyle mentions that the CSS battles scoring is based on accuracy and the least amount of code, but he prioritizes writing clean, understandable code that would make sense in a real-world application over minimalism.

  • What is the second CSS battle Kyle attempts in the video?

    -The second CSS battle Kyle attempts involves creating a design with five segments that have different colors and skewed shapes.

  • How does Kyle use the 'skew' property in the second CSS battle?

    -Kyle uses the 'skew' property to create the angled shapes required for the second CSS battle, experimenting with skewY to achieve the desired angle for the segments.

Outlines

00:00

🎨 Tackling CSS Challenges

In this segment, the speaker introduces a video tutorial focused on solving complex CSS challenges. The speaker plans to tackle never-before-seen CSS battles live, demonstrating their thought process for problem-solving, coding, and debugging. The goal is to provide viewers with insights into how to approach and overcome bugs in their own coding projects. The speaker, Kyle, begins with a Deadpool CSS battle, discussing the project's components and considering different approaches to creating shapes like black circles and eyes for the design.

05:02

🔍 Deep Dive into CSS Shapes and Positioning

The speaker continues to dissect the Deadpool CSS challenge, focusing on the creation and positioning of the black circles and eyes. They experiment with creating a full circle and cutting it in half versus using two separate circles. The process involves adjusting the size, position, and border radius to achieve the desired look. The speaker also addresses the creation of the eyes, which are half-circles, and the red band that cuts through the black circle. Attention is given to the precise alignment and sizing of these elements to match the reference design.

10:04

👁️‍🗨️ Perfecting the Eyes and Final Touches

In this part, the speaker refines the positioning of the eyes within the black circle and addresses a minor issue with the red band's height and the circle's overflow. They adjust the size and position of the eyes, ensuring they are correctly oriented and aligned. The speaker also discusses the importance of testing and fine-tuning the design to achieve a perfect fit, using tools like the diff mode to compare their work with the original design.

15:05

🎭 Exploring CSS Transformations and Skewing

The speaker moves on to another CSS challenge, focusing on creating a design with unique shapes. They discuss the use of the 'skew' property to achieve the angled shapes required for the design. Through trial and error, they find the correct skew values and positions for the elements. The segment highlights the process of adjusting the CSS properties to match the design's specifications and the importance of understanding how CSS transformations work.

20:06

📏 Aligning and Positioning Multiple CSS Elements

The speaker continues to work on the second CSS challenge, focusing on aligning and positioning multiple segments of the design. They use the 'skew' property to create angled shapes and adjust the top values and left properties to position the elements accurately. The segment emphasizes the importance of breaking down a complex design into smaller, manageable sections and the strategic use of CSS properties to achieve the desired layout.

25:07

🏆 Achieving 100% Accuracy in CSS Design

In the final segment, the speaker completes the second CSS challenge and submits their design for accuracy testing. They achieve a 100% match, validating their approach to breaking down the design into distinct sections and meticulously adjusting CSS properties. The speaker also promotes their CSS simplified course, emphasizing the importance of understanding CSS fundamentals for tackling complex CSS challenges with ease.

Mindmap

Keywords

💡CSS

CSS stands for Cascading Style Sheets, a stylesheet language used for describing the presentation of a document written in HTML or XML. In the context of the video, CSS is used to style and position elements on a webpage, creating visually appealing layouts. The video's theme revolves around solving CSS challenges, demonstrating how to apply CSS properties to build complex designs.

💡Web Development

Web development is the building and maintenance of websites; it includes aspects such as web design, web content development, and web server and network security configuration. The video is part of a web development tutorial series aiming to simplify the process of building websites, specifically focusing on front-end development using CSS.

💡Debugging

Debugging refers to the process of identifying and fixing errors or bugs in a program or software. In the video, debugging is mentioned as an essential skill when approaching coding problems, as it involves troubleshooting and resolving issues that arise during the development process, such as incorrect positioning or sizing of elements.

💡Flexbox

Flexbox is a CSS layout module that makes it easier to design flexible and responsive layout structures without using float or positioning. The video script mentions using 'display: flex' to center content, showcasing the use of Flexbox for aligning elements within a container.

💡Positioning

Positioning in CSS refers to the specification of an element's position in a document. The script discusses absolute, relative, and static positioning, which are crucial for placing elements accurately on a webpage, such as aligning the black circle and the eyes in the Deadpool mask design.

💡Border Radius

The 'border-radius' property in CSS is used to create rounded corners on elements' borders. In the video, border-radius is used to create circular shapes, like turning a div into a circle by setting the border radius to a value equal to half of the element's width and height.

💡Transform

The CSS 'transform' property applies a 2D or 3D transformation to an element. The video script describes using the 'transform' property to translate and rotate elements, such as adjusting the position of the black circle and skewing segments to achieve the desired angled shapes.

💡CSS Battle

CSS Battle is an online platform where users can improve their CSS skills by solving design challenges using only HTML and CSS. The video's presenter attempts to solve 'CSS battles' live, which involves creating specific designs with CSS, often requiring creative use of properties and a good understanding of layout techniques.

💡Sass

Sass, which is short for 'Syntactically Awesome Stylesheets', is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets. Although not explicitly mentioned in the script, the concept of writing clean and maintainable CSS, which is a theme in the video, is aligned with the benefits of using Sass.

💡Responsive Design

Responsive design ensures that web applications look good on all devices (desktops, tablets, and phones). While not directly discussed in the script, the theme of creating designs that work well across different screen sizes is implied in the video's focus on CSS, which is a fundamental aspect of responsive web design.

Highlights

Introduction to a video tutorial on solving complex CSS challenges live.

Emphasis on the thought process and problem-solving approach in web development.

Starting with a Deadpool CSS battle to demonstrate tackling a new challenge.

Strategic approach to breaking down project components for easier management.

Decision-making process between creating one full circle or two half-circles for design elements.

Live coding of the background and red section of the Deadpool mask.

Utilizing CSS properties like 'display: flex' and 'border-radius' for alignment and shaping.

Debugging and adjusting the positioning of design elements for accuracy.

Exploring different methods for creating the black circle element of the mask.

Live demonstration of coding and adjusting a black circle using CSS properties.

Discussion on the importance of centering elements and the use of 'position: absolute'.

Approach to creating a red band for the mask using the 'transform' property.

Live coding and positioning of the eyes on the Deadpool mask.

Technique for cutting a circle in half using border radius and height adjustments.

Final touch on positioning and rotating the eyes to complete the Deadpool mask.

Submission and scoring of the CSS battle to validate the accuracy of the design.

Reflection on the importance of writing clean, understandable CSS code over minimalism.

Transition to another CSS battle with a focus on creating shapes using the 'skew' property.

Live coding of a complex shape using CSS transformations for the first time.

Strategic segmentation of the design into reusable components for efficiency.

Final submission and validation of the second CSS battle with a focus on accuracy.

Promotion of a CSS course for deeper understanding and mastering CSS.

Transcripts

play00:00

in this video I'm going to show you my

play00:01

thought process for how I approach

play00:03

complex projects by attempting to solve

play00:05

multiple CSS battles entirely live these

play00:08

are CSS challenges I've never seen

play00:10

before and I'm going to go through my

play00:11

entire thought process of how I would

play00:13

approach it start writing some code

play00:14

debug live any problems that I run into

play00:16

and this is great for seeing how I

play00:18

actually approach problems how I

play00:19

overcome bugs I run into and you can

play00:21

really apply some of these skills to

play00:22

your own

play00:26

coding welcome back to web dev

play00:28

simplified my name is Kyle and my my job

play00:30

is to simplify the web for you so you

play00:31

can start building your dream project

play00:32

sooner I'm going to get started by

play00:34

tackling this Deadpool CSS battle which

play00:36

has like Wolverine Deadpool that's cuz I

play00:38

recently watched the Deadpool Wolverine

play00:39

movie great movie if you haven't seen it

play00:41

but I think this is going to be a great

play00:42

starting point cuz it doesn't look like

play00:43

it's too challenging but it's

play00:45

challenging enough it'll make me think

play00:46

through certain things so the very first

play00:48

thing I like to do when I approach a

play00:50

project like this is I like to look at

play00:51

all the different components and think

play00:52

about how they're going to work together

play00:54

obviously the background is super simple

play00:55

I just make a background that has that

play00:57

particular color same with this red

play00:58

section it's just going to be a red

play01:00

circle but the more complicated sections

play01:02

are going to be these black circles as

play01:04

well as the white eyes so this black

play01:06

circle the first thing that pops into my

play01:09

mind is I could create a shape that is

play01:10

essentially a black circle and cut it in

play01:13

half but the problem with that is you

play01:14

can see that this black circle is

play01:16

actually a full circle with like a

play01:18

middle segment taken out of it so if I

play01:20

create a normal circle with this height

play01:22

and this width and I cut it in half it

play01:24

may not give me the exact rounding that

play01:26

I want I may play around with both

play01:27

approaches of creating one big circle

play01:29

and putting a red strip down the middle

play01:31

and creating two separate circles and

play01:32

cutting them in half to see which one

play01:34

actually gives me the approach I want

play01:35

but those are the two ways I think about

play01:37

that problem now the eyes these look to

play01:39

be perfectly cut in half circles so I'm

play01:41

just going to create a circle cut it in

play01:42

half and that should be all that I need

play01:44

to do so to get started we can kind of

play01:46

tackle the easy things which is the

play01:47

yellow and the red sections so the very

play01:49

first thing I want to do is I'm going to

play01:50

have this div here which is going to be

play01:51

my background and I think actually I can

play01:53

probably just style the body I haven't

play01:54

done a CSS battle in a while but I think

play01:56

I can just say body and I can give it

play01:58

that exact color whoops this should be

play02:00

background color there we go paste that

play02:03

in and yep that did work exactly as I

play02:04

want now for this div this I'm just

play02:06

going to have to be the head wrapper

play02:09

there we go I'm going to give it this

play02:10

red color so we can say head

play02:15

wrapper background color is going to be

play02:18

that there we go and let's give it a

play02:20

height here it looks like maybe it says

play02:23

right here this is 400 by 300 pixels so

play02:25

the head's probably about 200 pixels

play02:27

tall and if we want to Center that we

play02:29

can do that here we can just do a

play02:32

display of

play02:35

flex and justify our content in the

play02:38

center and align our items in the

play02:42

center now if we give this a width which

play02:45

is probably also going to be 200 pixels

play02:47

and we round it with a border radius

play02:50

we'll just do 100% you can see we get a

play02:52

perfect circle and when I do my

play02:53

comparison here if I just do a little

play02:55

diff we'll notice that these green

play02:57

sections that appear mean that I am off

play02:59

on the shape and if I look at the

play03:00

comparison you can see that my shape is

play03:02

actually a little bit lower than the one

play03:04

above and it's also not quite big enough

play03:07

on the or it's a little bit too big on

play03:08

the bottom so I actually just need to

play03:09

move it up a little bit so it's actually

play03:11

not perfectly centered which I find a

play03:12

little bit strange yeah it does appear

play03:15

that it's just not perfectly centered so

play03:18

instead of doing this what I'm going to

play03:20

do is I'm just going to position this

play03:24

absolutely absolute just like that we'll

play03:26

say the left is going to be 100 pixels

play03:28

cuz that did look like it lined up

play03:29

perfectly left and right centered and

play03:31

the top here I'm going to do like 90

play03:33

pixels that does way too far so let's do

play03:36

actually yeah 45 pixels nope so it's

play03:38

going to be 50 pixels nope 55 pixels

play03:42

still not quite right 56 57 looks like

play03:44

I'm going the wrong way so 54 53 54

play03:47

looks like it's dead on the money as you

play03:49

can see there's pretty much no green

play03:50

coloring at all there's just a faint

play03:52

outline which is probably because my

play03:53

browser is slightly zoomed in if I zoom

play03:55

this out to 100% it's still there but

play03:57

either way it looks pretty good at that

play03:59

particular level now we can turn this

play04:00

diff mode off so we can actually see our

play04:02

product that we're working on and the

play04:03

next thing I want to work on is going to

play04:04

be the black circle and like I mentioned

play04:06

there's two different ways that I can

play04:07

approach this with either one Circle or

play04:09

multiple circles cut in half I'm going

play04:10

to get started by approaching it with

play04:12

the multiple circles cut in half just

play04:14

because I think that's the way that will

play04:15

not work but I'm interested to see if it

play04:17

actually will work so we can come in

play04:18

here and we can say that this is going

play04:20

to have a class which is going to be uh

play04:23

black circle there we go and I'll also

play04:27

give it the class of left so we know

play04:29

this is going to be the the left hand

play04:30

side close that off I'll copy this down

play04:33

cuz I'm going to have a right hand side

play04:35

as well so we'll come in here call this

play04:36

one right so now we have our black

play04:41

circle and for all of this we're going

play04:43

to put all of our generic classes inside

play04:45

of there and then we're going to have a

play04:46

black circle. left which is specifically

play04:49

for position it to the left so we'll

play04:50

come in

play04:52

here close that off and then we'll do

play04:54

the exact same thing for the right

play04:57

side just like that there we go so let's

play04:59

look on a black circle first obviously

play05:01

we need to give it a width and a height

play05:02

and a background color so we'll say

play05:04

background color and it is actually pure

play05:06

black so that's nice and easy we'll say

play05:08

the height here is going to be 90 pixels

play05:10

or something like that and we'll say

play05:12

that the width is going to be I don't

play05:14

know let's just say 90 pixels as well so

play05:16

we get essentially Perfect Circle

play05:18

obviously this is not showing up as a

play05:19

perfect circle I'm not really sure why

play05:21

my height and width are both exactly the

play05:23

same they're maybe something going on

play05:24

with the display going on in these oh

play05:26

it's because I have two black circles

play05:28

obviously stacked on top of each other

play05:29

that makes a lot of sense for now I'm

play05:30

going to comment this one out so I can

play05:32

work on just one of the circles at a

play05:33

time and obviously this height of 90 is

play05:35

not nearly big enough let's try 190

play05:37

that's going to be too big we'll just do

play05:39

150 I know it's probably not correct but

play05:41

we can kind of get started at that point

play05:43

and same thing here I'll make this 150

play05:45

now I will make my border radius 100% so

play05:48

we get a perfect circle and I'm going to

play05:49

try just doing a little bit of work to

play05:50

position this in the correct location so

play05:53

here I can do a top and essentially this

play05:55

is just going to be in the dead center

play05:57

so it should be 50% so I can say top 50

play05:59

50% and I can also say

play06:03

transform and I want to translate

play06:05

actually I'll just use the translate

play06:06

property and I want to translate

play06:08

essentially 0 and

play06:11

50% actually maybe

play06:13

50% 50% let me see what's going on here

play06:16

so if I have just a top of 50% that's

play06:19

not doing anything it looks like oh duh

play06:22

I should probably position my element

play06:24

absolutely first so absolute just like

play06:28

that and now if I add in this you can

play06:30

now see that this is perfectly hor or

play06:32

vertically aligned in the dead center

play06:34

just like I want it to be now I just

play06:35

want to offset it a little bit we'll say

play06:37

that maybe like the left property here

play06:39

is going to be like 10 pixels let's see

play06:42

we'll put the diff mode on not quite

play06:44

right it's probably going to be 20

play06:46

pixels still actually a little bit off

play06:49

if I turn it off div mode it looks like

play06:51

it's a little bit too big so we'll maybe

play06:52

say like 25 pixels that's obviously too

play06:56

far

play06:58

22 still might be too far so maybe it

play07:00

was going to be like 18 or

play07:02

something put that diff mode back on

play07:04

we'll see 17 that actually looks really

play07:07

good at 17 now we just need to make sure

play07:08

the height is correct cuz right now it's

play07:10

a little bit too tall at 150 so we will

play07:13

try 140 as our height that's actually no

play07:16

it's too small actually I need to make

play07:17

it a little bigger so 160

play07:21

165 164 it's going to be somewhere

play07:23

around there it looks like 164 lines up

play07:25

pretty well with this top section but

play07:27

you'll notice it's actually too wide my

play07:28

circle is currently too wide and that's

play07:31

because if we look at the arch you can

play07:32

see the arch doesn't quite line up

play07:34

exactly as it does before and that's

play07:35

because this thing I think is

play07:36

technically taller than it is wide just

play07:39

based on the way that this curve is

play07:41

working and I could try to fine-tune

play07:42

this by modifying my width for example

play07:44

making it 140 doesn't quite work making

play07:46

it 160 actually looks like it lines up

play07:48

pretty well if I try 170 it's going to

play07:52

probably go the other direction and we

play07:53

can see it does so 160 actually lines up

play07:56

really well with this it doesn't quite

play07:58

line up with the right hand side of my

play08:00

circle shape I bet if I make it 164 now

play08:03

I have a perfect circle still not far

play08:05

enough along in this direction so let me

play08:07

try making it a little bit wider we'll

play08:08

say 165 166 that actually looks really

play08:11

good we'll make this 166 and you'll

play08:14

notice now that the entire circle shape

play08:16

is essentially what I want it to be

play08:17

around that entire section but again

play08:19

you'll notice I now have just one full

play08:21

circle here doing a circle that was cut

play08:23

in half doesn't really work because

play08:24

again to get the curve to be perfectly

play08:26

aligned as you can see like I have right

play08:28

here to get that perfect lined curve I

play08:30

essentially need a circle that is this

play08:31

big so I would need to cut off

play08:33

essentially everything in this middle

play08:35

section to make it work or I could cut

play08:37

off everything to the right of here and

play08:38

then copy it and cut off everything to

play08:40

the left of this one in my case I'm just

play08:42

going to keep this one black circle get

play08:44

rid of these left and right classes I

play08:45

actually don't even need them if we go

play08:46

with just this particular approach and

play08:48

instead we can close off this there we

play08:51

go what I'm going to do is I'm going to

play08:52

have a band that essentially goes just

play08:54

right down the middle so we'll just call

play08:55

this red band and I don't have EMT in

play08:58

here so we'll say div class

play09:00

Red

play09:03

Band close that off there we

play09:07

go and we're going to have our red band

play09:10

and the Red Band for this one is just

play09:11

essentially going to be the full height

play09:12

of this so we can say height 100% let's

play09:16

do a width of like 20 pixels it'll

play09:17

probably have to be bigger than that the

play09:19

background

play09:21

color is just going to exactly match the

play09:24

color of this Deadpool Mask so we'll

play09:25

just copy that over there we go you can

play09:27

now see we have a red band I obviously

play09:29

need to position it in the very dead

play09:30

center so we'll do

play09:32

position absolute and we're going to

play09:35

come in here with a left of 50%

play09:39

translate of 50% that should put me in

play09:43

the exact dead center and now I just

play09:44

need to increase the size of this looks

play09:45

like it needs to be about doubled to 40

play09:47

pixels maybe 45 pixels actually that's

play09:50

too far we'll try 35 pixels that

play09:52

actually looks pretty good let me try 36

play09:55

versus

play09:56

37 I don't know I would say somewhere

play09:58

around there 35 36 somewhere around

play10:00

there looks really good where you can

play10:01

see if we toggle between these modes you

play10:03

really can't notice almost any

play10:05

perceivable difference between them and

play10:06

if there is any difference is most

play10:07

likely due to my zoom level now I'm

play10:09

going to change this to 165 and 165 to

play10:12

check to see if that actually looks good

play10:15

it actually looks like it's a little bit

play10:16

off on this diff mode so we'll go back

play10:18

to 166 166 it looks a little bit better

play10:20

still maybe not perfect but it looks

play10:21

pretty good at that level now the final

play10:23

step is going to be positioning the eyes

play10:25

in the center here for both of these so

play10:27

I can just put them inside this black

play10:28

circle so have a div we'll give it a

play10:31

class of I and we'll also say that this

play10:34

one is going to be the left because for

play10:35

these ones it really doesn't make sense

play10:37

to have both of these be the exact same

play10:39

div I mean that would be kind of crazy

play10:41

to do so we'll have the right and left

play10:43

eye and again we'll do this thing where

play10:45

we have our eye

play10:47

left and our eye right now before we get

play10:51

any further on the eye I did actually

play10:53

notice one thing just looking over at

play10:55

the side here there's a little bit of a

play10:56

black bar you can't really see it very

play10:58

well especially probably on YouTube is

play11:00

almost invisible but there's a slight

play11:02

back black bar at the very bottom and

play11:04

the top of this black circle that we

play11:07

have going on and that's because our red

play11:08

band is essentially just not quite tall

play11:10

enough I'm going to make it just a

play11:11

little bit taller than 110% so or than

play11:14

100% so we'll make it like

play11:15

110% and we're also going to set our

play11:17

black over or Circle to have an overflow

play11:20

of hidden so it doesn't actually Escape

play11:22

any of the bounds that actually still

play11:24

gives us that black bar if I zoom out it

play11:26

is still there that's interesting that

play11:27

that black circle is still up there so

play11:29

we'll get rid of the Overflow hidden

play11:31

we'll come in here we'll put a top of5

play11:34

pixels and this way we're just

play11:35

essentially getting 5 pixels of overflow

play11:37

on the top and bottom to get rid of that

play11:38

black you know halo effect that was

play11:40

showing up there it may be because of my

play11:42

browser my zoom level not 100% sure

play11:44

what's causing it but this at least will

play11:45

eliminate that particular problem now

play11:48

for these eyes they're going to be

play11:49

pretty similar to what we have here for

play11:50

this black circle so I'm just going to

play11:52

kind of copy all of this that we have

play11:55

paste it into here for the eye but

play11:57

obviously the background color for this

play11:58

one is all white as we can see over here

play12:00

the size is going to be significantly

play12:02

smaller so let's bump this down to like

play12:04

20 pixels so we have something much more

play12:05

reasonably sized to work with there we

play12:07

go it looks like it's going to be a

play12:09

little bit bigger than that but for now

play12:11

that at least is working as we expected

play12:12

to and I should probably make sure yeah

play12:14

both my eye right and my eye left are

play12:16

there I just need to make sure I

play12:17

position them in the correct location so

play12:19

they're not 100% in the very center so

play12:21

this top 50% really doesn't actually

play12:23

work instead I'll probably need to

play12:25

manually position it with some top and

play12:26

left values so let's go ahead and we'll

play12:28

start with a Top Value here let's just

play12:31

say we want to do 50

play12:33

pixels 90 pixels and I'm going to put

play12:35

this into diff mode so 90 looks like

play12:37

it's too far 60 is not far enough 70 80

play12:40

so we'll say it's probably somewhere

play12:41

around like 75 or so that looks pretty

play12:44

close and now we'll go with our left

play12:45

values we'll do like 20 maybe 25 that

play12:49

actually looks pretty good if I increase

play12:51

the size of this circle a little bit

play12:52

we'll do like 25 and 25 that looks

play12:55

really good actually maybe just needs to

play12:57

be a little bit biger actually so we'll

play13:00

make the width a little bit more we'll

play13:01

try

play13:02

30 and we'll make this 30 as well and

play13:07

we're just going to move the eyeball

play13:08

back a little bit so we'll try 70 here

play13:11

20 here maybe needs to be moved down a

play13:13

little bit

play13:15

too move this over a little bit maybe

play13:18

move it back one that actually looks

play13:20

really quite good it looks like it's in

play13:21

the exact right spot it just needs to be

play13:23

essentially cut in half if we move this

play13:25

off of div mode yeah it looks like it

play13:27

really just needs to be entirely cut in

play13:28

half now probably the easiest way for us

play13:30

to cut this shape in half is actually

play13:32

just to only put a border on one/ half

play13:35

of the shape and then essentially reduce

play13:37

the height of the shape in half so to

play13:39

show you what I'm talking about our

play13:40

border radius here we're just going to

play13:41

do it on the bottom left and let's do

play13:45

the bottom

play13:48

right there we go so now if we let that

play13:51

save real quick hopefully it should do

play13:53

something let's make it actually like a

play13:54

pixel value so we like 20 pixels for

play13:57

example same thing here 20

play14:01

pixels that's actually not quite working

play14:03

we'll move back to 100% And I think

play14:04

that's because I seem to say left bottom

play14:08

here let's try that I never remember the

play14:12

order of all these so we'll say that

play14:14

doesn't look like it's working so we'll

play14:16

say border left radius here we go we got

play14:20

bottom left and we got bottom top border

play14:23

bottom right

play14:25

radius there we go and now that has

play14:29

given us a simil or half circle shape

play14:31

but of course it's too tall if we cut

play14:33

our height in half we should hopefully

play14:35

get that shape correct I just need to

play14:36

make sure that this value right here is

play14:38

essentially a pixel value so we'll say

play14:39

30 pixels because it needs to be

play14:41

essentially a value that is the same as

play14:43

our width so we'll say 30 pixels here

play14:45

and now you can see I get a perfect

play14:46

semicircle shape that is exactly what I

play14:48

want now I just need to rotate this so

play14:51

we can come in here with a rotate we'll

play14:52

try 30° at first that actually looks

play14:55

like the perfect rotation so that was a

play14:56

pretty good guess on my part I just need

play14:57

to move it down a little bit and to the

play14:59

left so we'll say here that we're going

play15:01

to do left a little bit we'll say I

play15:03

don't know let's do it back a couple

play15:05

pixels with like

play15:06

15 16 17 18 now let's try moving it down

play15:11

so we'll do like 67 oops that's not

play15:13

right direction we need to do like 75 6

play15:16

7 8 and I need to maybe move it left

play15:20

just a little bit

play15:21

more 18 and actually maybe need to

play15:24

rotate it like 29°

play15:27

28 27 looks like 28 is about correct and

play15:31

maybe move it down just a little bit

play15:34

more whoops that's the wrong direction

play15:37

still the wrong direction that actually

play15:38

is probably about correct let's do this

play15:40

in normal mode looks like I maybe have

play15:42

it slightly too big on the ey size so

play15:44

we'll say like 29 here and I'll just

play15:47

copy that down to these values here

play15:48

let's actually do 28 so we can get

play15:50

exactly in half for a height 28 and this

play15:53

would be 14 let's see if that shrunk it

play15:56

down enough it looks pretty close we'll

play15:58

try moving it up a little

play16:00

bit Yeah I'd say that's pretty close it

play16:02

doesn't have to be perfect looks like

play16:04

it's a little bit small now which is

play16:06

kind of an interesting take so maybe the

play16:08

29 was the correct

play16:10

value there we

play16:11

[Music]

play16:13

go and we'd probably just need to move

play16:15

it back down just a little

play16:19

bit yeah it's it's a little bit tall I

play16:22

don't know I think it's close enough

play16:23

though it only moves a very very slight

play16:25

amount when I look at it in diff mode

play16:27

it's almost exactly perfect so I'd say

play16:28

say that that's probably good enough now

play16:31

all I need to do here is change what

play16:33

I've essentially done for my left so

play16:35

this will be down here so I can get rid

play16:36

of this left value on this section and

play16:39

the I right should just have a right of

play16:41

18 pixels and I just need to rotate the

play16:43

I the other direction so we move the

play16:45

rotate down into here to be -28 and it

play16:48

looks like that is exactly what we want

play16:50

but it's positioned possibly in the

play16:52

wrong location so I think maybe it's

play16:55

because I need to change something about

play16:57

my rotation

play16:59

let's see exactly why that is or maybe

play17:00

my right value needs to be modified a

play17:02

little bit there you go actually just

play17:03

adding one to that looks like that was

play17:05

exactly what I needed to make this work

play17:07

and the way that we can test to see if

play17:09

this actually works is just by clicking

play17:10

submit and it'll give us a ranking

play17:11

essentially between 0 and 100% for how

play17:14

close we are to what the actual thing

play17:15

looks like and I got a score of 601 that

play17:17

essentially means I have 100% accuracy

play17:19

on this you can see 100% accuracy now

play17:22

the scoring the way that CSS battle

play17:24

works is based on the least amount of

play17:25

code that you write but I generally

play17:26

don't actually follow that I just like

play17:28

to write the code in the way that makes

play17:29

the most sense cuz generally writing the

play17:31

smallest amount of code makes you do a

play17:32

lot of really hacky weird things that

play17:33

you would never do in a real world

play17:35

application and I try to make this about

play17:36

as close as possible to a real world

play17:38

application now let's go back and see if

play17:40

we can tackle something else on the CSS

play17:41

battle so we'll just go to the overall

play17:43

all the different battles and just kind

play17:44

of see what there is that pequs our

play17:46

interest actually I kind of like this

play17:47

one right here which kind of works with

play17:48

some weird shapes going on so we'll just

play17:50

do this one right here so the very first

play17:52

thing I like to do is just get rid of

play17:53

all this extra code we really don't need

play17:54

it and I actually like to put my CSS

play17:56

Styles at the top it's just more like

play17:58

how I actually write CSS so here we go

play18:00

this is what we're going to work on

play18:01

first of all we're going to get our body

play18:02

color the most straightforward thing we

play18:04

can

play18:06

do background color is going to be just

play18:09

like that there we go and then we

play18:10

essentially just have two different

play18:12

types of shapes that we're going to be

play18:13

giving these two different colors so I

play18:15

have 1 2 3 four five different segments

play18:17

that I want to do and the interesting

play18:19

thing to note is that segment one and

play18:21

five and segment two and four are

play18:23

essentially the exact same thing they're

play18:24

just positioned in slightly different

play18:26

locations so that shouldn't actually be

play18:28

that hard for me to do so we can come

play18:29

into here and we can specify different

play18:31

segments that we have so we can say

play18:33

segment one which should be essentially

play18:35

the same as segment 5 there we go I'm

play18:38

going to put them both in the same

play18:39

selector and then we're going to have

play18:41

segment two and also segment

play18:44

4 and those are going to be in the exact

play18:47

same

play18:48

selection and then finally segment three

play18:53

now to actually style these segments is

play18:55

essentially just going to be creating a

play18:57

rectangle and I think what we're going

play18:58

to want to do is use the skew property

play19:00

to give us this angled shape on it but

play19:02

I'm not 100% sure it's not a property I

play19:04

use almost at all in my day-to-day CSS

play19:06

work so let's just go ahead and we're

play19:08

just going to get started with something

play19:09

really simple I'll create a single div

play19:11

and we're just going to give it a class

play19:13

of segment one just to get us something

play19:17

to get started with background

play19:21

color is going to be this color right

play19:24

here there we go width let's just say

play19:27

it's going to be 50 pixels

play19:29

and we'll do a height of 100 pixels just

play19:31

so we can see it on the screen there we

play19:33

go we have it right there I should

play19:35

probably get rid of any padding that I

play19:36

have on here as well or margin there we

play19:39

go that way we have nothing extra

play19:40

showing up on our screen and now I'm

play19:42

going to just move this down I think

play19:44

it's just it's actually not quite

play19:46

centered I don't think but we can try

play19:47

centering it we can say top

play19:49

50% position

play19:53

absolute and we can say translate 0 and

play19:59

50% there we go that should translate us

play20:01

to the correct location doesn't look

play20:02

like it's moving though and I think

play20:04

that's cuz there should be no comma here

play20:05

there we go so it actually looks like it

play20:08

may actually be centered it looks like

play20:10

it is actually lining up perfectly and I

play20:11

think I actually have the height of this

play20:12

element right the width is also correct

play20:15

actually that's kind of surprising all I

play20:16

need to do is try to skew it into the

play20:18

correct location so I think the skew

play20:19

property is what I need but like I said

play20:21

I almost never used this so we'll say

play20:24

transform skew and we'll see exactly

play20:27

what we need to do here so let's try

play20:28

skew X and we'll just put in a value I

play20:30

think it's based on degrees so we'll say

play20:31

20° obviously that looks to be the wrong

play20:34

direction for the skew so we'll say -20°

play20:37

and this actually doesn't quite look

play20:38

like what I want because I only want the

play20:40

tops and the bottoms to be moving I

play20:42

don't actually want the sides of it so

play20:44

let's try skewing in the y direction

play20:45

there we go that is actually what we

play20:46

want we'll do 20° we do a little diff on

play20:50

this and now let's try skewing it a

play20:52

little bit further maybe it's

play20:55

25° nope 25 there we go that looks like

play20:59

it lines up perfectly for the angle of

play21:02

the thing now I just need to make sure

play21:03

the position is correct it looks like I

play21:04

need to move it down a little bit

play21:06

further and that's because the skew

play21:08

essentially just moved the position of

play21:09

this so I'm going to put this Top Value

play21:11

in pixels we'll get rid of this

play21:12

translate because we don't actually need

play21:13

it so we'll say 100 pixels see if that

play21:16

lines up we'll use the diff tool for

play21:17

this

play21:19

120

play21:21

110

play21:22

105 looks like 110 was pretty close

play21:26

let's come in here and look at this

play21:28

maybe I need to skew it slightly more in

play21:30

One Direction or the other so we like

play21:32

26° that actually might be more correct

play21:35

and we'll try moving this down just a

play21:36

little bit that actually looks perfect

play21:38

so if we look at the actual view here

play21:40

and analyze yeah I can't really notice

play21:41

any difference between these so this is

play21:43

a good example of me kind of knowing

play21:45

about this skew property I should

play21:46

probably capitalize the Y here just so

play21:47

it looks a little better so doesn't say

play21:49

skewy so it's just a thing that I was

play21:51

familiar with this skew property I've

play21:53

never really used it all I knew is that

play21:55

it was a way to make shapes kind of bend

play21:56

a little bit and have this little angle

play21:58

to them and just by tinkering around I

play22:00

was able to stumble upon the correct

play22:01

answer but a lot of times just stumbling

play22:04

upon the correct answer doesn't happen

play22:05

like I noce SK X doesn't work and skew

play22:07

doesn't work and skew y I happen to find

play22:10

out is the one that worked but if I

play22:11

didn't ever find out what was working

play22:12

and I knew that skew was probably what I

play22:14

wanted I could just easily go to ndn

play22:16

look up the documentation for skew they

play22:18

have tons of examples and I would find

play22:20

an example that essentially looked like

play22:21

this and I'd be like oh that's probably

play22:23

what I need so now that we have segments

play22:25

done I want to come in here with a

play22:27

second or uh separate selector for

play22:29

segment one and that's going to be

play22:31

specifically just for positioning the

play22:33

left property so where do I have the

play22:35

left property obviously I don't have a

play22:36

left property so we'll do segment five

play22:38

here because obviously this is as far

play22:40

left as it goes so I'm going to copy

play22:42

this do segment five and all I want to

play22:44

do is say right of zero and there we go

play22:46

that should put it in the correct

play22:47

location but it looks like it doesn't it

play22:49

is way off it needs to be either lower

play22:52

or higher so I'm going to move my Top

play22:53

Value up into segment

play22:57

one there we go segment one put a Top

play22:59

Value in here and this one I'm going to

play23:01

have a separate Top Value which is going

play23:02

to be pretty similar so we'll start with

play23:03

100 pixels and I'll move the Top Value

play23:06

out of here there we go let's do

play23:09

90 80 there we go and I think I need to

play23:11

go a little lower so 85

play23:14

86 oops pixels there we go 87 there we

play23:18

go 87 looks perfect so we'll keep it

play23:20

just like that so now I have everything

play23:22

for Segment 1 and five entirely done now

play23:25

we can move on to segment two which is

play23:26

going to be pretty similar so I'll just

play23:28

take the code in here directly copy this

play23:30

I'll make sure I add a semicolon to the

play23:32

end of here just because that's good

play23:33

practice for when you're writing actual

play23:34

CSS code background color for this one

play23:37

is going to be this darker color so

play23:38

we'll paste that in and the width for

play23:41

these is going to be quite a bit wider

play23:43

so I'll come in here we'll get segment

play23:45

two and four and I might as well while

play23:47

I'm at it add in segment three so

play23:50

segment two is going to have the exact

play23:51

same height but I believe the width is

play23:53

probably about double so we'll say it's

play23:54

going to be 200 pixels sorry 100 pixels

play23:57

for the width there we go and now all I

play23:58

need to do is just move it down to the

play24:00

position that I want it to be so we can

play24:02

come into here and select just segment

play24:06

two there we go and I'm actually going

play24:08

to move this code up a little bit

play24:11

into here abouts there we go just so I

play24:15

get it in between segment one and

play24:16

segment 5 to kind of keep it aligned a

play24:18

little bit better we'll minimize these

play24:20

back down and this one is just going to

play24:22

have a Top Value there we

play24:25

go and for now I think I'm actually

play24:27

going to comment out segment four so it

play24:28

doesn't get in the way of what I'm

play24:29

working on also my skew direction is

play24:32

probably going to be the exact same but

play24:34

with a negative value so let me come

play24:35

into here change this to a negative

play24:37

value and skew me upwards instead of to

play24:39

the downward Direction so my left

play24:41

property let's see if just putting in 50

play24:43

pixels lines me up and of course it does

play24:44

that is great now all we need to do is

play24:46

move this down a little bit more so

play24:48

we'll do 90 95 maybe even 100 actually

play24:51

100's looking very close let's try 101

play24:54

102 it's going the wrong way try 99 98

play24:57

99

play24:59

that looks really quite good let's see

play25:02

yeah I really don't notice almost any

play25:04

difference other than it needs to

play25:05

actually move down a little bit so let's

play25:06

try 100 yeah 100 looks really good I

play25:09

like that looks like the skew is maybe a

play25:12

little off though because if I look at

play25:13

the far right side it should be bent

play25:15

down a little bit more so I might

play25:17

actually have to skew this slightly more

play25:19

for example we'll just come into the

play25:21

diff mode here we'll see how this looks

play25:23

with 27 versus 25 26 27

play25:28

27 looks decent let me just try moving

play25:31

this up a little bit 99

play25:35

pixels 98

play25:38

99

play25:40

100 oops

play25:42

99 it looks pretty good I think what I'm

play25:45

going to do is I'm just going to go back

play25:46

to when I had 26 move this to 100 and I

play25:49

think that's probably good enough again

play25:50

it's probably just a little bit of

play25:51

zooming of my browser if I zoom it out a

play25:53

little bit still off by a little bit but

play25:56

honestly you get the gist it's pretty

play25:57

much the exact same thing so now we can

play25:59

mess with segment number four so we can

play26:01

come in here segment four is essentially

play26:04

the exact same thing but I need to

play26:05

change this to be the right property

play26:08

just like that I want to comment segment

play26:10

4 back in and if we look at the diff

play26:13

mode it actually lines up perfectly so

play26:15

we don't really need to change anything

play26:16

at all which is great because the top

play26:18

value for Segment four and two is the

play26:20

same so we can just leave it directly

play26:21

into there and take it out of here I'm a

play26:24

little bit curious why the top segment

play26:25

or the Top Value was different for

play26:27

segment one versus segment 5 little bit

play26:29

strange but overall nothing really to

play26:31

worry about now the final segment is

play26:33

going to be segment number three which

play26:34

actually looks to have the same skew as

play26:36

the other ones so we'll come into here

play26:37

with segment three I'm going to copy

play26:40

essentially everything I have in here

play26:41

this one is going to be at positive 26°

play26:43

the color is going to be slightly

play26:45

different for this one and we need to

play26:47

specify our left property which I

play26:49

believe is just going to be 150

play26:52

pixels there we go and that actually

play26:53

does line up properly now we just need

play26:55

to make the height of this a little bit

play26:56

bigger so I think it's going to be 200

play26:58

which which will drop our Top Value by

play27:00

50 and it looks like that actually just

play27:02

lines up perfectly we don't even need to

play27:03

make any other changes so the nice thing

play27:05

about this shape the way that I kind of

play27:06

analyze it this whole entire CSS design

play27:09

is I was able to break it down into

play27:10

distinct sections I notice section one

play27:12

and section 5 are identical just placed

play27:14

in slightly different locations same

play27:16

things with section 2 and section 4 they

play27:18

are identical just again placed in

play27:20

slightly different locations and section

play27:21

3 is really just like a really big

play27:23

version of Section 1 and section 5 if we

play27:26

actually look at the code for Segment 3

play27:27

here you can see this one has a width of

play27:29

50 and a height of 100 for Segment 1 and

play27:30

5 this is just a width of 100 height of

play27:32

200 so it's literally just doubled the

play27:34

values of the previous one relatively

play27:35

straight forward and now if I do a quick

play27:37

submission I should hopefully see that I

play27:39

have 100% accuracy on this I'd be pretty

play27:41

surprised if I didn't because it's

play27:42

really pretty much exactly there and if

play27:44

I close out of this you'll notice we get

play27:45

100% match now if you want to be able to

play27:48

tackle CSS problems like this with

play27:50

relative ease I highly recommend

play27:51

checking out my CSS simplified course

play27:53

it's linked down in the description

play27:55

below this course covers everything you

play27:56

need to know about CSS from the absolute

play27:58

Basics all the way up to complex things

play28:00

like animations and responsive designs

play28:02

and the best part is it really Builds on

play28:04

the core fundamental knowledge of

play28:05

understanding how CSS Works which makes

play28:08

it really easy to write more complex CSS

play28:10

code since you know exactly what each

play28:12

line of CSS is doing that's why I

play28:14

created this course to really help me

play28:16

and other people understand CSS at a

play28:18

fundamental level so if you're

play28:19

interested in that I highly recommend

play28:20

you check it out in the description down

play28:22

below with that said thank you very much

play28:24

for watching and have a good day

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
CSS BattlesWeb DevelopmentLive CodingProblem SolvingKyle's CourseCSS TechniquesWeb DesignTutorialCoding SkillsEducational
Benötigen Sie eine Zusammenfassung auf Englisch?