Components and Layout Patterns Flashcards
CSS: How to center an element with a width of 700px?
.accordion{
width: 700px;
margin: 100px auto;
}
How to add an icon to your page?
At heroicons.com look for the .svg tag and and simply add it to the page
How to quickly copy class names for the css?
Alt + select and then copy
Address more elements than one?
.number, .text{}
.hidden-box ul{
margin-left: 20px;
}
.hidden-box li{
margin-bottom: 12px;
}
How to do this better in flexbox?
.hidden-box ul {
margin-left: 20px;
display: flex;
flex-direction: column;
gap: 12px;
}
How to change alignment direction in flexbox? What are the implications for the other properties?
flex-direction: column;
align-items goes horizontally
justify-content goes vertically
gap acts like margin-bottom
How to add gaps in CSS grid?
column-gap: 24px
row-gap: 32px
In VS code, how can you simply collapse a part?
Hit the arrow on the left?
Note: When copy/pasting this, it will paste in NON collapsed form
In CSS property, how to vary between visible and not-visible?
Visibility property
Vary between block and hidden
visibility: visible;
visibility: hidden;
Difference between display and visibility property?
The visibility CSS property shows or hides an element without changing the layout of a document.
To both hide an element and remove it from the document layout, set the display property to none
What will happen when setting only the height of an image?
The propertions of the image will be maintained?
CSS property: How to set all text in the container to white
color: #fff
Will apply to all text in the referred to container
How to typically start with a new bit of content?
Put all the content there and work from there
How to apply the rest of the colors apart from the base color?
Use a color style sheet (for testimonial text for example)
When wanting to use an image that you want to let fall out of the boundaries of the container, what property would you use?
And which properties to position it correctly?
transform: scale(1.8)
(for example)
Then use inspect to keep track of the center of the image. Use gap and padding to make the image come out properly
How to apply shadow?
box-shadow: 0 12px 24px rgba(0,0,0,0.1)
Offset, blur, color
How would you use the inspector in your design
Checking and unchecking buttons and see the results
When applying two round buttons for backward and forward, what properties could be necessary?
background-color
border: none
height, width
position: absolute
border radius: 50%
display: flex, align and justify –> To center icon
What is probably going wrong here with the alignment unless intentional? (left and right button)
.btn{
background-color: #fff;
border: none;
height: 40px;
width: 40px;
position: absolute;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 12px 24px rgba(0,0,0,.2);
cursor:pointer;
The buttons will not be aligned to the center of the container but will be lower than that because it adds the height of that element.
To resolve: transform: translate();
Use left and right in separate css and set the dimensions of each while
.btn–left {
/* In relation to PARENT ELEMENT */
left: 0;
top: 50%;
/* In relation to ELEMENT ITSELF */ transform: translate(-50%, -50%); } .btn--right { right: 0; top: 50%; transform: translate(50%, -50%); }
Set cursor to pointer
cursor: pointer
If you don’t want to use flexbox, what could you use instead apart from CSS Grid?
Absolute positioning is sometimes favored
Can you overwrite paddings after having set a general padding?
Yes
How to build a table in html?
Start like with emails
Body > table > tr > td
Good to note that tables are not used that much anymore due to the rise of flexbox
Table: How would you address to head row?
<thead> for head row
<tbody> for rest
Nesting:
table > thead > tr > td
table > tbody > tr > td
</tbody></thead>
Table: How to distinguish between head row and the rest of the table?
Head row: Use thead
Body row: Use tbody
Table: How to let an element in the table stand out?
Use <th> in stead of <td> for an element
What can you use instead of margin: 0 auto?
display:flex
justify-content: center
Table: How to prevent that there’s a double border?
border-collapse: collapse;