Posts

Showing posts with the label CSS

[CSS Grid]

Image
1. Create Your First CSS Grid Turn any HTML element into a grid container by setting its display property to grid. This gives you the ability to use all the other properties associated with CSS Grid. Note: In CSS Grid, the parent element is referred to as the container and its children are called items. 2. Add Columns with grid-template-columns Simply creating a grid element doesn't get you very far. You need to define the structure of the grid as well. To add some columns to the grid, use the grid-template-columns property on a grid container as demonstrated below: .container { display : grid ; grid-template-columns : 50px 50px ; } add   grid-template-columns : 100 px 100px 100px ; 3. Add Rows with grid-template-rows The grid you created in the last challenge will set the number of rows automatically. To adjust the rows manually, use the grid-template-rows property in the same way you used grid-template-columns in the previous challenge. add  grid-template-row...

[CSS Flexbox 2/2]

Image
1. Use the flex-wrap Property to Wrap a Row or Column CSS flexbox has a feature to split a flex container into multiple rows (or columns). By default, a flex container will fit all flex items together. For example, a row will all be on one line. However, using the flex-wrap property tells CSS to wrap items. This means extra items move into a new row or column. The break point of where the wrapping happens depends on the size of the items and the size of the container. CSS also has options for the direction of the wrap: nowrap: this is the default setting, and does not wrap items. wrap: wraps items onto multiple lines from top-to-bottom if they are in rows and left-to-right if they are in columns. wrap-reverse: wraps items onto multiple lines from bottom-to-top if they are in rows and right-to-left if they are in columns. The current layout has too many boxes for one row. Let me Add the CSS property flex-wrap to the #box-container element, and give it a value of wrap. 2. Use the flex-sh...

[CSS Flexbox 1/2]

Image
 Flexbox is a powerful, well-supported layout method that was introduced with the latest version of CSS, CSS3. With flexbox, it's easy to center elements on the page and create dynamic user interfaces that shrink and expand automatically. In this course, you'll learn the fundamentals of flexbox and dynamic layouts by building a Twitter card. 1. Use display: flex to Position Two Boxes This section uses alternating challenge styles to show how to use CSS to position elements in a flexible way. First, a challenge will explain theory, then a practical challenge using a simple tweet component will apply the flexbox concept. Placing the CSS property display: flex; on an element allows you to use other flex properties to build a responsive page. Let me Add the CSS property display to #box-container and set its value to flex. 2. Add Flex Superpowers to the Tweet Embed To the right is the tweet embed that will be used as a practical example. Some of the elements would look better with a...

Responsive Web Design Principles

1.  Create a Media Query Media Queries are a new technique introduced in CSS3 that change the presentation of content based on different viewport sizes. The viewport is a user's visible area of a web page, and is different depending on the device used to access the site. Media Queries consist of a media type, and if that media type matches the type of device the document is displayed on, the styles are applied. You can have as many selectors and styles inside your media query as you want. Here's an example of a media query that returns the content when the device's width is less than or equal to 100px: @media ( max-width : 100px ) { /* CSS Rules */ } and the following media query returns the content when the device's height is more than or equal to 350px: @media ( min-height : 350px ) { /* CSS Rules */ } Remember, the CSS inside the media query is applied only if the media type matches that of the device being used. 2. Make an Image Responsive Making images re...