Closed github-learning-lab[bot] closed 3 years ago
In your CSS file:
.body{}
) #### CSS selectors are used to "find" (or select) the HTML elements that you want to style. ```css .body{ } ```
Inside the selector, set the display
attribute to flex
Set the justify-content
and align-items
attributes to center
so your items are centered on the y axis and the x axis respectively.
You may also want to set the min-height
to 100vh
so that height of your content will always be relative to the size of the screen.
Inside the body, you can also change the color of the background, as well as the color, font, and size of your text.
I recommend using the font-family
attribute with a few backup fonts in case your browser doesn't support your font of choice.
You can add back up fonts by following your font with a comma and another font family or type. My font-family line looks like this:
font-family: "Trebuchet MS", Verdana, sans-serif;
```css body{ display: flex; justify-content: center; align-items: center; min-height: 100vh; font-family: "Trebuchet MS", Verdana, sans-serif; font-size: 25px; background: #a5b8d9; color: #fff; } ```
At this point, your webpage should look something like this:
Just as you did for your previous tasks, be sure create a new branch, titled [your GitHub username]-[week]-[task number]
, for your task. For example, my GitHub username is danzelo1
so my branch name for week 2's second task (this assignment) would be danzelo1-2-2
.
After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch. When creating this request, be sure to title it appropriately in accordance with your changes, and include any specific details in your comments.
As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week (so this week would be week 2). A new comment should have appeared for your next task. This is where you'll find the instructions for task 3.
After you're satisfied with the body of your page, you'll move on to designing your clock.
clock
class.
div
we created in the last assignment that prints the time on your screen. div
tag only has an id
property, be sure to go back to your HTML file and add a class
attribute set to "clock"
.Within your .clock
selector:
Set the width
to 500px
and height
to 200px
. This will define the rectangle in which the time is printed.
Add a background and a solid border using colors different from the screen's background so you can see what the box will look like.
background-color
and border
attributes for these items respectivelySet the display
to flex
Center the text using align-items
and justify-content
You may also want to adjust the margins of your clock so that theres some space between the box and the form - I simply adjusted the left margin of my clock.
This is what my code looks like after these steps:
```css .clock{ width: 500px; height: 200px; font-size: 90px; background: #102; border: 20px solid black; display: flex; align-items: center; justify-content: center; margin-left: 50px; } ```
Now, you may notice that my border appears slightly different than yours- this is because I used the CSS box-shadow tool to create some depth to my clock and add additional borders. This effect is in no way required, but if you'd like to learn more about it, click below!
![picture](https://i.imgur.com/bsQld9J.png) The first number in each line represents the x-offset which is the horizontal distance from which you want the object to appear. The second number is the y-offset - the vertical distance from which the box will appear. The third number is the blur radius - a larger blur radius will create a bigger shadow and vice versa. Lastly is the color. I used the rgba() tool to define my color. The first 3 numbers represent the amount of red, green, and blue in the color, respectively. The fourth number is the opacity on a scale from 0 to 1, with 0 being complete transparency and 1 being fully opaque. This tool can be very intimidating so I suggest using a box-shadow generator, such as [this one](https://html-css-js.com/css/generator/box-shadow/) and playing around with the options so that you can understand what's going on a little better and simply copy the code generated.
Once again, be sure create a new branch, titled [your GitHub username]-[week]-[task number]
, for your task.
After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch.
As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week. A new comment should have appeared for your next task where you'll find the instructions for task 4.
Lastly, you're going to style the labels and buttons used for your timezone selector.
Define a selector that targets your timezone elements.
div
with its class
property set to "timezone"
. If you're already satisfied with how your page looks because of how you styled the body, then this part is unnecessary, but I recommend you do some styling here to get a better hang of CSS attributes.
font-family
, or the font-size
, or even the font-color
- use your creativitity with this task.This is what my page looks like after this step:
Once again, be sure create a new branch, titled [your GitHub username]-[week]-[task number]
, for your task.
After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch.
As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. This is the last task for week 2, so you're all done!
What was confusing about this week? If you could change or add something to this week, what would you do? Your feedback is valued and appreciated!
Pretty straight-forward to follow instructions easy to follow. Maybe some more detail could be added about possible customisations within selectors, animations etc.
Task 1: Linking your CSS file
How to begin a CSS file and link it to your HTML file.
This week, we're going to take the HTML and JavaScript code we wrote last week and style our page using CSS to make it more aesthetically pleasing.
First, let's create a new folder to hold your files.
Once you have Visual Studio Code open, you can style your webpage.
First we must link a CSS file to our HTML file.
Add a
link
tag inside the head of your html fileSet the
rel
attribute of thelink
tag to"stylesheet"
, and itshref
attribute to"style.css"
.Having issues? Click me!
style.css
.href
attribute in your HTML file, as this will be what links your two files.Task 1 Checklist:
Open a pull request for your code
Just as you did for your previous tasks, be sure create a new branch, titled
[your GitHub username]-[week]-[task number]
, for your task. For example, my GitHub username isdanzelo1
so my branch name for week 2's first task (this assignment) would bedanzelo1-2-1
.After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch. When creating this request, be sure to title it appropriately in accordance with your changes, and include any specific details in your comments.
As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week (so this week would be week 2). A new comment should have appeared for your next task. This is where you'll find the instructions for task 2.