DEV Community

Cover image for CSS Battle #1 - Simply Square

CSS Battle #1 - Simply Square

Olzhas Askar on June 04, 2019

I am one of those people, who like to think that knowing only HTML and CSS is not enough. I know, it is unfair and I don’t even need to prove anyth...
Collapse
 
aklevansky profile image
Anton Klevansky

Clever trick with box shadows. I tried to make shorten the code with linear gradients:
body{background:linear-gradient(90deg,rgba(0,0,0,0) 50%,rgb(93,58,58)0),linear-gradient(rgb(181,224,186)200px, rgb(93,58,58)0)}</p>

Collapse
 
lance2k profile image
lance2k

CSS is extremely difficult. At least, for me. So, I decided to try to get my hands dirty with it. Luckily, there is a nice interactive website with CSS challenges. And who doesn’t like challenges?
Because the score requires the solution to be correct in the first and be short in the second, I’d prefer to concentrate on correctness.

Lol it's 2023 and I'm currently in the same boat (I just recently started my web dev journey). I like your post and will be following you and this series : )

Collapse
 
christophwessels profile image
Christoph Weßels • Edited

Better solution with 54 Characters:

Collapse
 
caseyeee profile image
Casey Echternacht

This is a great series; thanks for putting it together

Collapse
 
tomek24 profile image
tOmek24 • Edited

My first solution is 80 Characters:
body bgcolor=#5d3a3a><div style="width:0;margin:-8;border:100px solid #b5e0ba"

when using img instead of div you can do without the "width" attribute.
72 Characters solution.

body bgcolor=#5d3a3a><img style="margin:-8;border:100px solid #b5e0ba"

Collapse
 
systemx profile image
Mohammed Fellak

Can anyone look into PILOT BATTLE?
my solution is 249 characters

body {background:#E3516E;display:flex;place-items:center;justify-content:center;}div {padding: 100px;border-radius: 50%;background: conic-gradient(#FADE8B 90deg,#E3516E 90deg 180deg,#F7F3D7 180deg 270deg,#51B5A9 270deg 360deg);}

But i've found some one who did it in way less then that, any idea how?

Collapse
 
lakshayasood profile image
Lakshaya Sood

great solutions. Are there any other sites where I can test my css skills.

Collapse
 
verheyenkoen profile image
Koen Verheyen

Switch the <img> out for an <a>-tag and you pitch off 2 chars.

Collapse
 
tuxhedoh profile image
Tuxhedoh

Thanks for sharing these. My initial answer was the first one. But I worked through the other answers just to see how they work.

Collapse
 
pheeria profile image
Olzhas Askar

Cool!
The more difficult the tasks get, the fewer variations I have. But I still try to find at least the second one.

Collapse
 
sagarrth profile image
Sagar Rout

When i started with the 1st challenge, my instinct was solution 2. After going through the other variations, it really opened my eyes. I got to improve a lot.
Appreciate your article a lot

Collapse
 
pheeria profile image
Olzhas Askar

Thanks! Check out the other challenges as well!

Collapse
 
chetanam profile image
Chetan

My with 106chars made me learn box-shadow though which will be useful in card

Collapse
 
sidonaldson profile image
Simon Donaldson

Use the html and body tags

html{background: #5d3a3a;}body{width:50vw;height:50vw;background:#b5e0ba;margin:0}

Collapse
 
johanroug profile image
Johan Roug • Edited

my solution. I simply style the bodytag, and use * instead of body.
90 char

*{background:#b5e0ba;margin:0;box-shadow:-150px -50px 0 50px #5d3a3a inset}

Collapse
 
jmad13 profile image
jmad13

You can use the vw unit in the height to maintain a square ratio

width: 50vw;
height: 50vw;