NTM Solutions

Thứ Ba, 24 tháng 4, 2018

Khóa học CSS - Bài 29 - Thư viện ảnh

Quay về MỤC LỤC TỰ HỌC CSS

1. Thư viện ảnh

Ví dụ:
<html>
<head>
<style>
div.gallery 
{
    margin
: 5px;
    border
: 1px solid #ccc;
    float
: left;
    width
: 180px;
}

div.gallery:hover 
{
    border
: 1px solid #777;
}

div.gallery img 
{
    width
: 100%;
    height
: 300px; /*Nếu chiều cao hình bằng nhau thì để auto*/
}

div.desc 
{
    padding
: 15px;
    text-align
: center;
}
</style>
</head>
<body>

<div class="gallery">
  
<a target="_blank" href="hinh\hinh01.jpg">
    
<img src="hinh\hinh01.jpg" alt="Fjords" width="300" height="200">
  
</a>
  
<div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  
<a target="_blank" href="hinh\hinh02.jpg">
    
<img src=" hinh\hinh02.jpg " alt="Forest" width="300" height="200">
  
</a>
  
<div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  
<a target="_blank" href="hinh\hinh03.jpg">
    
<img src="hinh\hinh03.jpg" alt="Northern Lights" width="300" height="200">
  
</a>
  
<div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  
<a target="_blank" href="hinh\hinh04.jpg">
    
<img src="hinh\hinh04.jpg" alt="Mountains" width="300" height="200">
  
</a>
  
<div class="desc">Add a description of the image here</div>
</div>

</body>
</html>

2. Thư viện ảnh responsive

<!DOCTYPE html>
<html>
<head>
<style>
/*Chú ý các tấm hình sử dụng phải có kích thước bằng nhau*/
div.gallery {
    border: 1px solid #ccc;
}

div.gallery:hover {
    border: 1px solid #777;
}

div.gallery img {
    width: 100%;
    height: auto;
}

div.desc {
    padding: 15px;
    text-align: center;
}

* {
    box-sizing: border-box;
}

.responsive {
    padding: 0 6px;
    float: left;
    width: 24.99999%;
}

@media only screen and (max-width: 700px) {
    .responsive {
        width: 49.99999%;
        margin: 6px 0;
    }
}

@media only screen and (max-width: 500px) {
    .responsive {
        width: 100%;
    }
}

.clearfix:after {
    content: "";
    display: table;
    clear: both;
}
</style>
</head>
<body>

<h2>Responsive Image Gallery</h2>
<h4>Resize the browser window to see the effect.</h4>

<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="hinh\hinh01.jpg">
      <img src="hinh\hinh01.jpg" alt="Trolltunga Norway" width="300" height="200">
    </a>
    <div class="desc">Add a description of the image here</div>
  </div>
</div>


<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="hinh\hinh02.jpg">
      <img src="hinh\hinh02.jpg" alt="Forest" width="600" height="400">
    </a>
    <div class="desc">Add a description of the image here</div>
  </div>
</div>

<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="hinh\hinh03.jpg">
      <img src="hinh\hinh03.jpg" alt="Northern Lights" width="600" height="400">
    </a>
    <div class="desc">Add a description of the image here</div>
  </div>
</div>

<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="hinh\hinh04.jpg">
      <img src="hinh\hinh04.jpg" alt="Mountains" width="600" height="400">
    </a>
    <div class="desc">Add a description of the image here</div>
  </div>
</div>

<div class="clearfix"></div>

<div style="padding:6px;">
  <p>This example use media queries to re-arrange the images on different screen sizes: for screens larger than 700px wide, it will show four images side by side, for screens smaller than 700px, it will show two images side by side. For screens smaller than 500px, the images will stack vertically (100%).</p>
  <p>You will learn more about media queries and responsive web design later in our CSS Tutorial.</p>
</div>

</body>
</html>

Nếu vẫn chưa rõ, các bạn xem thêm video clip sau:

Quay về MỤC LỤC TỰ HỌC CSS


Tác giả: #drM

Nguồn: Sưu Tầm

Thứ Hai, 23 tháng 4, 2018

Khóa học CSS - Bài 28 - Hiệu ứng dropdown

Quay về MỤC LỤC TỰ HỌC CSS


Trong thiết kế web có 01 hiệu ứng rất hay được sử dụng:

Rê chuột ngang qua đối tượng-> sổ xuống 01 cái gì đó: gọi là hiệu ứng dropdown.

1. Dropdown cơ bản

Ví dụ: rê chuột ngang qua đối tượng-> xổ xuống 01 nội dung

<style>
.dropdown 
{
    position
: relative;
    display
: inline-block;
}

.dropdown-content 
{
    display
: none; /*ẩn đối tượng khi chưa rê chuột qua*/
    position
: absolute;
    background-color
: #f9f9f9;
    min-width
: 160px;
    box-shadow
: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding
: 12px 16px;
    z-index
: 1;
}

.dropdown:hover .dropdown-content 
{
    display
: block;
}
</style>

<div class="dropdown">
  
<span>Mouse over me</span>
  
<div class="dropdown-content">
    
<p>Hello World!</p>
  
</div>
</div>

Chủ Nhật, 22 tháng 4, 2018

Khóa học CSS - Bài 27 - Menu điều hướng

Quay về MỤC LỤC TỰ HỌC CSS


1. Menu điều hướng là 01 danh sách các liên kết

Ví dụ:

Ban đầu, ta tạo danh sách các liên kết:

<ul>
  <li><a href="default.asp">Home</a></li>
  <li><a href="news.asp">News</a></li>
  <li><a href="contact.asp">Contact</a></li>
  <li><a href="about.asp">About</a></li>
</ul>


Sau đó bỏ dấu bullet và định dạng:

ul {
    list-style-type
: none;
    margin
: 0;
    padding
: 0;
}

Nếu muốn hiển thị menu nằm ngang ta có 02 cách thiết lập với li:

li {    float: left;   }

Cách này các bạn nhớ khống chế thẻ div tiếp theo bằng thuộc tính clear ( xem lại bài Tự học CSS - Bài 20 - Thuộctính float và clear).

Hoặc cũng có thể thiết lập như sau với thẻ li:

li {    display: inline;   }

Mấy phần “râu ria” như tô màu nền, bỏ gạch dưới trong liên kết, hiệu ứng hover,… các bạn tự mày mò xem sao.
Thứ Bảy, 21 tháng 4, 2018

Khóa học CSS - Bài 26 - Thuộc tính trong suốt opacity và transparency

Quay về MỤC LỤC TỰ HỌC CSS


·         Opacity là độ trong suốt của phần tử HTML
·         Thuộc tính này nhận giá trị từ: 0.0-1.0

Ví dụ:

img {
    opacity
: 0.5;
    filter
: alpha(opacity=50); /* For IE8 and earlier */
}

1. Chuyển độ trong suốt kết hợp hiệu ứng :hover


Ví dụ 1:
img {
    opacity
: 0.5;
    filter
: alpha(opacity=50); /* For IE8 and earlier */
}

img:hover
{
    opacity
: 1.0;
    filter
: alpha(opacity=100); /* For IE8 and earlier */
}

Ví dụ 2: tạo chiếc hộp trong suốt

div {
    opacity
: 0.3;
    filter
: alpha(opacity=30); /* For IE8 and earlier */
}
Thứ Sáu, 20 tháng 4, 2018

Khóa học CSS - Bài 25 - Phần tử giả lập Pseudo-elements

Quay về MỤC LỤC TỰ HỌC CSS

1. Cú pháp và công dụng của phần tử giả lập

·         Cú pháp:

Tên thẻ chọn::tên phần tử giả lập{thuộc tính: giá trị}

Ví dụ:

h1::after {
    content
: url(linh.jpg);
}

·         Công dụng:
o   Định dạng dòng đầu tiên, chữ đầu tiên của đối tượng đã chọn.
o   Chèn nội dung dung vào trước (before) hoặc sau(after) nội dung phần tử đã chọn.

2. Phần tử giả lập ::first-line

Ví dụ:

p::first-line {
    color
: #ff0000;
    font-variant
: small-caps;
}
Facebook Youtube RSS