Skip to content

Commit 0fc97af

Browse files
committed
4 Responsive Web Design Principles - FREECODECAMP
1 parent 430cac1 commit 0fc97af

File tree

9 files changed

+84
-0
lines changed

9 files changed

+84
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<style>
2+
p {
3+
font-size: 20px;
4+
}
5+
/* Only change code below this line */
6+
7+
@media(max-height:800px) {
8+
p {
9+
font-size: 10px;
10+
}
11+
}
12+
/* Only change code above this line */
13+
</style>
14+
15+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis tempus massa. Aenean erat nisl, gravida vel vestibulum cursus, interdum sit amet lectus. Sed sit amet quam nibh. Suspendisse quis tincidunt nulla. In hac habitasse platea dictumst.
16+
Ut sit amet pretium nisl. Vivamus vel mi sem. Aenean sit amet consectetur sem. Suspendisse pretium, purus et gravida consequat, nunc ligula ultricies diam, at aliquet velit libero a dui.</p>
17+
18+
<!-- 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
19+
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
20+
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:
21+
@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. Add a media query, so that the p tag has a font-size of 10px when the device's height is less
22+
than or equal to 800px. -->
287 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<style>
2+
.responsive-img {
3+
max-width: 100%;
4+
height: auto;
5+
}
6+
7+
img {
8+
width: 600px;
9+
}
10+
</style>
11+
12+
<img class="responsive-img" src="https://s3.amazonaws.com/freecodecamp/FCCStickerPack.jpg" alt="freeCodeCamp stickers set">
13+
<img src="https://s3.amazonaws.com/freecodecamp/FCCStickerPack.jpg" alt="freeCodeCamp stickers set">
14+
15+
<!-- Make an Image ResponsivePassed Making images responsive with CSS is actually very simple. You just need to add these properties to an image: img { max-width:
16+
100%; height: auto; } The max-width of 100% will make sure the image is never wider than the container it is in, and the height of auto will make the image keep its original aspect ratio. Add the style rules to the responsive-img class to make it responsive.
17+
It should never be wider than its container (in this case, it's the preview window) and it should keep its original aspect ratio. After you have added your code, resize the preview to see how your images behave. -->
282 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<style>
2+
img {
3+
width: 100px;
4+
height: auto;
5+
}
6+
</style>
7+
8+
<img src="https://s3.amazonaws.com/freecodecamp/FCCStickers-CamperBot200x200.jpg" alt="freeCodeCamp sticker that says 'Because CamperBot Cares'">
9+
10+
<!-- Use a Retina Image for Higher Resolution Displays
11+
12+
With the increase of internet connected devices, their sizes and specifications vary, and the displays they use could be different externally and internally. Pixel density is an aspect that could be different on one device from others and this density is known as Pixel Per Inch(PPI) or Dots Per Inch(DPI). The most famous such display is the one known as a "Retina Display" on the latest Apple MacBook Pro notebooks, and recently iMac computers. Due to the difference in pixel density between a "Retina" and "Non-Retina" displays, some images that have not been made with a High-Resolution Display in mind could look "pixelated" when rendered on a High-Resolution display.
13+
14+
The simplest way to make your images properly appear on High-Resolution Displays, such as the MacBook Pros "retina display" is to define their width and height values as only half of what the original file is. Here is an example of an image that is only using half of the original height and width:
15+
16+
<style>
17+
img { height: 250px; width: 250px; }
18+
</style>
19+
<img src="coolPic500x500" alt="A most excellent picture">
20+
21+
Set the width and height of the img tag to half of their original values. In this case, both the original height and the original width are 200px.
22+
-->
275 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<style>
2+
h2 {
3+
width: 80vw;
4+
}
5+
6+
p {
7+
width: 75vmin;
8+
}
9+
</style>
10+
11+
<h2>Importantus Ipsum</h2>
12+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis tempus massa. Aenean erat nisl, gravida vel vestibulum cursus, interdum sit amet lectus. Sed sit amet quam nibh. Suspendisse quis tincidunt nulla. In hac habitasse platea dictumst.
13+
Ut sit amet pretium nisl. Vivamus vel mi sem. Aenean sit amet consectetur sem. Suspendisse pretium, purus et gravida consequat, nunc ligula ultricies diam, at aliquet velit libero a dui.</p>
14+
<!--
15+
Make Typography Responsive Instead of using em or px to size text, you can use viewport units for responsive typography. Viewport units, like percentages, are relative units, but they are based off different items. Viewport units are relative to the viewport
16+
dimensions (width or height) of a device, and percentages are relative to the size of the parent container element. The four different viewport units are: vw (viewport width): 10vw would be 10% of the viewport's width. vh (viewport height): 3vh would
17+
be 3% of the viewport's height. vmin (viewport minimum): 70vmin would be 70% of the viewport's smaller dimension (height or width). vmax (viewport maximum): 100vmax would be 100% of the viewport's bigger dimension (height or width). Here is an example
18+
that sets a body tag to 30% of the viewport's width. body { width: 30vw; } Set the width of the h2 tag to 80% of the viewport's width and the width of the paragraph as 75% of the viewport's smaller dimension. -->
269 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Responsive Web Design Principles
2+
3+
There are many devices that can access the web, and they come in all shapes and sizes. Responsive web design is the practice of designing flexible websites that can respond to different screen sizes, orientations, and resolutions.
4+
5+
In this course, you'll learn how to use CSS to make your webpages look good, no matter what device they're viewed on.

0 commit comments

Comments
 (0)