Showing posts with label web design. Show all posts
Showing posts with label web design. Show all posts

Sunday, 1 May 2016

Project 02: Forms & Buttons

After recently reading the W3Schools Chapter on HTML Forms, I thought to myself, "Hey, you know what would be neat for my next project, creating a sheet of lovely looking log-in designs." It's gotten to a stage now where I, unashamedly, find that kind of idea just plain tasty.


I found what I would loosely describe as a tutorial on Codrops, Creative Button Styles. You're supplied with the CSS and the Javascript and, to be honest, it was pretty much all Javascript and therefore very irrelevant to what I'm currently learning (one step at a time, am I right?), but I liked the idea and rolled with it. 

If you're interested Colour Lovers is where I found all of these delicious colour schemes. From top to bottom: Odd but Trendy, Pink Parrot, Blue Kitten, none, Sand & Bikini

In the first example, you can see a fade transition between blue to purple on hover. I achieved this by setting opacity: 1; within the button class, then adding a transition on hover:

button:hover.btn-1 {
   transition: .XXs ease-in-out;
   background-color: purple;
}

The .XXs specifies how long in seconds you wish the transition to take, and the ease-in-out property specifics it should be a steady and linear fade. To eliminate any fade transitions when active - as this can look a little messy - simply set the opacity back to 1 with a 0s transition time:

button:active.btn-1 {
   opacity: 1;
   transition: .0s; 
}

This is followed by 3 simple designs of simply changing the colour of the box, borders and text on hover. While this relies heavily on the palette, these simple hover changes can feel very responsive and demonstrate clearly to the user that they are interactable elements. While it may be a little overkill in this demonstration, it still has a juiciness to it.

In the final example, I tried to make the buttons appear as though they were being pressed down on hover then on click, as in the first Codrops example (but remember, there's no Javascript here yet). Therefore, I just played around with reducing the sizes of the top and bottom borders to give the illusion it was being pressed in. Let's look how that's coded:

.btn-5 {
   border-bottom: 4px solid #7391b6;
   border-top: 2px solid #4ed4d8;
   padding-top: 3px;
}

button:hover.btn-5 {
   border-bottom: 2px solid #7391b6;
   border-top: 4px solid #f0e3f2;
   padding-top: 0px;
}

button:active.btn-5 {
   border-bottom: 0px solid #7391b6;
   border-top: 6px solid #f0e3f2;
}

First up, when :active, visually the element shifts, so there's some code needed there that I haven't yet got to the bottom of. 


What's happened here, is we have three different colours: #7391b6 (dark blue), #4ed4d8 (blue) and #f0e3f2 (pink).  The background colour is pink, so when defining the button, we add an "invisible" blue border (the same colour as the button itself) to the top of 2px, meaning, when we hover we make that top border bigger at 4px and change its colour to pink, so it appears as though the button has moved down 4px even though the top border has actually increased in size. We have simultaneously reduced the bottom border (dark blue, to make it appear 3D) to give the impression the button is now inset. The padding keeps the elements locked in position when their border sizes are shifting. 

It's important to do the maths here, making sure to flip the top and bottom border pixel values and add the necessary amount of padding. 

Again, this is far from perfect, but if you want to try it for yourself, or see exactly what I did here, you can find the code here:

 

Friday, 15 April 2016

Project 01: Fighting the Link Formatting

As mentioned previously, I found the task of styling elements that doubled up as an <a> tag to be a tricky task indeed. I still feel that way, so instead of taking on the whole beast with one swing, I decided to extract the "Read More" section of The Telegraph and work on that singularly. It definitely helps, and what I came up with wasn't perfect, but it was definitely a lot more manageable.
While I'm sure any untrained eye can spot the difference (mimicking formatting is proving hard) the key task of getting these links to colour and hover correctly worked like a charm. Using specificity seemed key to success here (thank you, Khan Academy CSS Specificity). While I'm sure it would be more beneficial to up my class game, using definitions such as ol li { } gave me the right amount of control.

I've pasted the code I made for this into a Paste Bin (also included below) for anyone to nosey at. I'm happy enough for now, but that's still not happy enough. I will integrate this mini-project into my main code and go from there.
 

Thursday, 14 April 2016

Project 01: Recreating The Telephraph

While I'm not one to be found nose-deep in a broadsheet, let alone The Telegraph, I have to admire the simplicity of their site design, especially when learning to recreate existing CSS content. At least that what I expected this project to be like, but when I finally got pen to paper, I realised just how wrong I was.


A job like this takes a lot of planning, and the nuances within the design have proven to be unexpectedly complex. I've struggled with defining the number of <div> elements I require, scared to add more as the list of classes and tags extends longer and longer. Editing headings and other elements that also double up with the <a> tag has also been difficult - having to style a:link, a:visted, a:hover sometimes individually and sometimes not picking up changes at all. Furthermore, trying to style the numbers in a list seemed near impossible until I found this nifty tutorial which instead utilised the <span> tag (Design Shack - 5 Simple and Practical CSS List Styles You Can Copy and Paste).

While I haven't looked around yet, it would also be nice to have a colour-picker desktop app - no more copying images into Photoshop, thank you very much. I suspect there might be a tool out there for this, if not, hold that thought!

The article in particular that I'm trying to mimic is the 15 maps that will change the way you see the world travel piece. It contains a lot of images, lists, links and interesting formatting qualities. I thought it would prove an interesting challenge while not been beyond my range.
At first glance, I'm not sure if my current attempt would fool anyone, but the building blocks are definitely in place. As you can clearly see, I'm struggling with the positioning, trying to wrap my head around absolute and relative, margin and padding in particular. 

There are also the colouring issues I mentioned when dealing with an element that is both a heading/p element and a <a> tag. For reasons I don't yet understand, their style only applies correctly on hover. 

As a first pass, I'm happy to keep banging my head against the wall until I get to the bottom of this. I hope, by the next major update, to have fixed the positioning and link colouring issues.