آموزش outline در CSS

آموزش outline در CSS

 

در این آموزش قصد داریم با outline آشنا بشیم. نوع تعاریفی که برای outline وجود دارد مثله border است. با این تفاوت که به جای کلمه border از outline استفاده میکنیم. ولی در بخش نمایش، این دو با هم تفاوت هایی دارند.

به مثال زیر دقت کنید.

 

<!DOCTYPE html>
<html>
<head>
  <title>lesson</title>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="lesson.css">
</head>
<body>
  <div class="test">
      hello world!<br>
      hello world!<br>
      hello world!
  </div>

  <div class="test">
      hello world!<br>
      hello world!<br>
      hello world!
  </div>

  <div class="test">
      hello world!<br>
      hello world!<br>
      hello world!
  </div>

  <div class="test">
      hello world!<br>
      hello world!<br>
      hello world!
  </div>
</body>
</html>

 

.test:nth-child(2n){
  background-color: red;
}

.test:nth-child(2n+1){
  background-color: yellow;
}

.test{
  margin: 20px;
  border-radius: 10px;
  padding: 20px;
}

div:hover{
  margin: 30px;
  color: blue;
}

 

 

 

حال بیاید outlineی تعریف کنیم با ویژگی dotted به رنگ مشکی و همچنین در حین hover رنگ outline به رنگ آبی تغییر کند. میتوانید با سر زدن به آموزش border ها، طریقه درست تعریف را آموزش ببینید و فقط به جای کلمه border از outline استفاده میکنیم.(click here)

 

.test:nth-child(2n){

background-color: red;

}

 

.test:nth-child(2n+1){

background-color: yellow;

}

 

.test{

margin: 20px;

border-radius: 10px;

padding: 20px;

outline: black dotted 5px;

}

 

div:hover{

margin: 40px;

color: blue;

outline-color: blue;

}

 

 

 

حال بیاید هم زمان یک boder به رنگ صورتی تشکیل دهید تا به صورت دقیق تر تفاوت border و outline را متوجه شوید.

 

.test:nth-child(2n){
  background-color: red;
}

.test:nth-child(2n+1){
  background-color: yellow;
}

.test{
  margin: 20px;
  border-radius: 10px;
  padding: 20px;
  outline: black dotted 5px;
  border: pink solid 4px;
}

div:hover{
  margin: 40px;
  color: blue;
  outline-color: blue;
}
استفاده از outline در CSS
 

همانطور که میبینید outline با فاصله بیشتری از border قرار میگیرد.

 

برای دیدن آموزش های بیشتر جزوات CSS را دنبال کنید.

 

قسمت قبل آموزش (آموزش padding در CSS)

قسمت بعد آموزش (آموزش width و height در CSS)

ارسال دیدگاه

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *


Warning: file_put_contents(): Only -1 of 3235 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 13578 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 9638 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 293 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 4037 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 1722 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 180 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 3815 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Warning: file_put_contents(): Only -1 of 15074 bytes written, possibly out of free disk space in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176

Fatal error: Uncaught ErrorException: file_put_contents(): write of 8192 bytes failed with errno=122 Disk quota exceeded in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php:176 Stack trace: #0 [internal function]: litespeed_exception_handler(8, 'file_put_conten...', '/home/farkia/do...', 176, Array) #1 /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php(176): file_put_contents('/home/farkia/do...', '<!DOCTYPE html>...', 8) #2 /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/optimizer.cls.php(136): LiteSpeed\File::save('/home/farkia/do...', '<!DOCTYPE html>...', true, true) #3 /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/optimize.cls.php(837): LiteSpeed\Optimizer->serve('https://farkian...', 'js', true, Array) #4 /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/optimize.cls.php(387): LiteSpeed\Optimize->_ in /home/farkia/domains/farkiantech.com/public_html/wp-content/plugins/litespeed-cache/src/file.cls.php on line 176