кнопки

Оформление кнопок HTML


кнопка



<a href="#" class="knopka01">кнопка</a>

А дальше экспериментируем со стилями

<style type="text/css">
a.knopka1 {
  background: rgba(172, 173, 125, 0.5);
  padding: 5px 7px;
  text-decoration: none;
  outline: none;
  color: #000;
  border-radius: 2px;
  border: 1px solid #878857;
  box-shadow: 0px 1px 1px #878857, inset 0px 0px 1px #dcdd89, inset 0px 1px 0 #dcdd89;
  text-shadow: 0px 1px 1px rgba(255,255,255,1);
} 

a.knopka1:hover { background: rgba(172, 173, 125, 1); } 

a.knopka1:active {
  box-shadow: 0px 1px 1px #fff, inset 0px 1px 0px #878857, inset 0px 0px 1px #878857;} 
</style>

<a href="#" class="knopka1">кнопка</a>
кнопка

Чтобы добавить к кнопке картинку или спец.символы, можно применить псевдоэлементы

<style type="text/css">
a.knopka1:after {
  content: " \2613";
}

a.knopka1:hover:after {
  content: " \2713";
}

a.knopka1:active:after, a.knopka1:visited:after, a.knopka1:focus:after {
  content: " \2714";
}
</style>
кнопка

Многие любят градиенты

<style type="text/css">
a.knopka1 {
  background-image: -moz-linear-gradient(#a9a57f, #827e55);
  background-image: -ms-linear-gradient(#a9a57f, #827e55);
  background-image: -o-linear-gradient(#a9a57f, #827e55);
  background-image: -webkit-linear-gradient(#a9a57f, #827e55); 
} 

a.knopka1:hover {
  background: -moz-radial-gradient(#fff, #827e55);
  background: -ms-radial-gradient(#fff, #827e55);
  background: -o-radial-gradient(#fff, #827e55);
  background: -webkit-radial-gradient(#fff, #827e55);
}
</style>
кнопка

Часто вижу вариант с чёткой границей посередине

<style type="text/css">
a.knopka1 {
  background-image: -moz-linear-gradient(#cbc8ad 0%, #c1be9d 50%, #8f8b63 50%, #827e55);
  background-image: -ms-linear-gradient(#cbc8ad 0%, #c1be9d 50%, #8f8b63 50%, #827e55);
  background-image: -o-linear-gradient(#cbc8ad 0%, #c1be9d 50%, #8f8b63 50%, #827e55);
  background-image: -webkit-linear-gradient(#cbc8ad 0%, #c1be9d 50%, #8f8b63 50%, #827e55); 
} 
</style>
кнопка

Не обязательно сразу иметь вид кнопки

<style type="text/css">
a.knopka3 {
  padding: 7px 10px;
  text-decoration: none;
  outline: none;
  border-radius: 2px;
} 

a.knopka3:hover { 
  box-shadow: rgba(255,255,255,.2) 0px 1px 1px, inset rgba(0,0,0,.5) 0 1px 4px;
  background: -moz-linear-gradient(rgba(0,0,0,.1), rgba(0,0,0,0) 30%, rgba(0,0,0,.2));
  background: -ms-linear-gradient(rgba(0,0,0,.1), rgba(0,0,0,0) 30%, rgba(0,0,0,.2));
  background: -o-linear-gradient(rgba(0,0,0,.1), rgba(0,0,0,0) 30%, rgba(0,0,0,.2));
  background: -webkit-linear-gradient(rgba(0,0,0,.1), rgba(0,0,0,0) 30%, rgba(0,0,0,.2));
} 

a.knopka3:active {background: rgba(0,0,0,.3);} 
</style>

<a href="#" class="knopka3">кнопка</a>
кнопка

Второй вариант CSS кнопки

Воспользуемся position: relative

<style type="text/css">
a.knopka2 {
  color: #fff; font-weight: bold;
  background: rgba(172, 173, 125, 1);
  padding: 5px 7px;
  text-decoration: none;
  outline: none;
  border-radius: 5px;
  box-shadow: 1px 3px 0px #555231, 2px 4px 1px rgba(0, 0, 0, 0.3);
  text-shadow: 0 -1px 0 #595206;
} 

a.knopka2:hover {background: #9a955e;} 

a.knopka2:active {
  top: 2px; left: 1px; position: relative;
  box-shadow: 0px 1px 0px #555231;} 
</style>

<a href="#" class="knopka2">кнопка</a>
кнопка

Анимированная кнопка CSS

Добавим анимацию с постоянным изменением фона

<style type="text/css">
a.knopka3 {
  background: #fff;
  padding: 5px 7px;
  text-decoration: none; outline: none;
  color: #666;
  border: 1px solid #DDD;
  border-radius: 3px;
  -moz-animation: animaciya 3s infinite alternate;
  -webkit-animation: animaciya 3s infinite alternate;
  -ms-animation: animaciya 3s infinite alternate;
} 

a.knopka3:hover {
  -webkit-animation-play-state:paused;   
  -moz-animation-play-state:paused;
  -ms-animation-play-state:paused;
} 

@-moz-keyframes animaciya {   
  from {background: #fff;}  
  to {background: #acad7d; border: 1px solid #878857; color: #fff;} 
}

@-webkit-keyframes animaciya {
  from {background: #fff;}  
  to {background: #acad7d; border: 1px solid #878857; color: #fff;} 
}

@-ms-keyframes animaciya {
  from {background: #fff;}  
  to {background: #acad7d; border: 1px solid #878857; color: #fff;} 
}

a.knopka3:active {
   border: 1px solid #AAA;
   border-bottom-color: #CCC;
   border-top-color: #999;
   box-shadow: inset 0 1px 2px #aaa;
} 
</style>

<a href="#" class="knopka3">кнопка</a>
кнопка

Круглые CSS кнопки

<style type="text/css">
a.krug {
  position: relative;
  display: inline-block;
  height: 50px; width: 50px; line-height: 50px;
  text-align:  center;
  text-decoration: none;
  outline: none;
  background: #cecbb7; 
  box-shadow: inset 0 1px 0 #747161, 0 1px 0 #fff;
  color: #4f3f0d;
  border-radius: 100%;
}

a.krug:after {
  content: "";
  position: absolute;
  top: 3px; right: 3px; bottom: 3px; left: 3px; 
  box-shadow: inset 0 1px 0 #fff; 
  border: 1px solid #959055;
  border-radius: 100%;
}

a.krug:active:after {
  box-shadow: 0px 1px 1px #fff;
}
</style>

<a href="#" class="krug">ВКЛ</a>
ВКЛ
<style type="text/css">
a.krug1 { text-indent: 0px;
  display: inline-block;
  height: 40px; width: 40px; line-height: 40px;
  text-align:  center;
  text-decoration: none;
  outline: none;
  color: #4f3f0d;
  border-radius: 100%;
  box-shadow: inset 0px 2px 0 #fff, inset 0px 0px 1px #fff, 0px 1px 0 #93835c;
  border: 1px solid #b09f79;
}

a.krug1:hover {
  background: -moz-linear-gradient(rgba(246, 236, 192, 1), rgba(236, 226, 202, 1));
  background: -ms-linear-gradient(rgba(246, 236, 192, 1), rgba(236, 226, 202, 1));
  background: -o-linear-gradient(rgba(246, 236, 192, 1), rgba(236, 226, 202, 1));
  background: -webkit-linear-gradient(rgba(246, 236, 192, 1), rgba(236, 226, 202, 1)); 
}

a.krug1:active {
  box-shadow: inset 0px 0 1px #fff, 0px 1px 0 #fff;
}
</style>

<a href="#" class="krug1">вкл</a>
вкл

Выпуклая кнопка HTML


выпуклая кнопка

Объёмная кнопка CSS

объёмная кнопка

border

значение устанавливает рамку одновременно для четырёх краёв элемента
первое значение определяет рамку для верхней и нижней границы, второе - левой и правой
первое значение задаёт рамку для верхней, второе - для правой и левой, третье - нижней стороны
значения поочерёдно используются для верхнего, правого, нижнего и левого края
border-style
border-color
inherit

inherit

inherit

inherit
border-width
thin
medium
thick
inherit
thin
medium
thick
inherit
thin
medium
thick
inherit
thin
medium
thick
inherit
1
13
div {
border: none; /* или */
border-top: none; border-right: none; border-bottom: none; border-left: none; /* или */ border-style: none; border-color: rgb(34, 34, 34); border-width: medium; /* или */ border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: rgb(34, 34, 34); border-right-color: rgb(34, 34, 34); border-bottom-color: rgb(34, 34, 34); border-left-color: rgb(34, 34, 34); border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; }

Модальное окно

Событие click на нескольких элементах с одним input

Для того, чтобы lightbox работал, я пришла к этой конструкции (это двигатель моей "машины"):


<!-- input должен находится выше изображений. У него не должно быть родителя, который при этом не является родителем label. Чтобы не путаться, input располагайте после <body> -->
<input type="checkbox" id="click"/>
<br>
<label for="click"></label>
<br>
<label for="click"></label>


Модальное окно

Очень простое в реализации, "легкое" и вместе с тем позволяет включать любое содержание модальное окно. Не заданы фиксированные ширина и высота, блок располагается по центру, растягивается под содержание и под разрешение монитора.
<style type="text/css">
.vkl { cursor: zoom-in; cursor: -moz-zoom-in; cursor: -webkit-zoom-in;}

.lightbox {
  display: none;
  height: 100%; width: 100%;
  position: fixed; top: 0%; left: 0%;}

.lightbox:target {display: table;}

.lightbox > div {
  vertical-align: middle;
  display: table-cell;
  text-align: center;
}

.lightbox > div > div {
  display: inline-block;
  position: relative;
}

.video {  
  width: 50%;
  position: fixed; top: 12%; left: 25%;
  display: none;}

.lightbox > div > div, .video {
  padding: 8px;
  background: #fff;
  text-align: left;
  box-shadow: 0 0 5px #fff;
  z-index: 101;
}

.lightbox img {width: 100%; padding: 0px; display: block;}

.video > div {
  padding-bottom:75%;
  height: 0;
  position: relative;}

.video iframe, .video object, .video embed {position: absolute; left: 0; top: 0;}

a[href="#close"] {
  position: fixed; top: 0; bottom: 0; right: 0; left: 0;
  z-index: 100;
  cursor: zoom-out; cursor: -moz-zoom-out; cursor: -webkit-zoom-out;
  background: rgba(0, 0, 0, 0.6);
  text-align: right;
  font-size: 200%; 
  padding-right: 7px;
  text-decoration: none;
  color: #cccccc;
  display: none;}

a[href="#close"]:hover {color: #fff;}

.video:target, .video:target ~ a[href="#close"], .lightbox:target ~ a[href="#close"] {display: block;}
</style>

<a href="#showimage1" class="vkl">Образец</a>

<div class="lightbox" id="showimage1">
  <div>
    <div>
      <img src="адрес_изо"/>
      Текст
    </div>
  </div>
</div>

<a href="#close">✖</a>
Образец
Для видео несколько отличается HTML код:
<a href="#showimage2" class="vkl">Образец</a>

<div class="video" id="showimage2">   
  <div>
    <iframe width="100%" height="100%" src="адрес_видео" frameborder="0" allowfullscreen></iframe>
  </div>
  Текст
</div>

<a href="#close">✖</a>
Образец

Текст
Реализация происходит с помощью псевдокласса :target. Стили достаточно прописать один раз, а id блока должен быть индивидуальным. Например, так:
<a href="#showimage1" class="vkl">Раз</a><a href="#showimage2" class="vkl">Два</a><a href="#showimage3" class="vkl">Три</a>

<div class="lightbox" id="showimage1">
  <div>
    <div>
      <a href="#showimage3">◄</a> ॥ <a href="#showimage2">►</a>
      <img src="адрес_изо"/>
      Текст
    </div>
  </div>
</div>

<div class="lightbox" id="showimage2">
  <div>
    <div>
      <a href="#showimage1">◄</a> ॥ <a href="#showimage3">►</a>
      <img src="адрес_изо"/>
      Текст
    </div>
  </div>
</div>

<div class="video" id="showimage3">  
  <a href="#showimage2">◄</a> ॥ <a href="#showimage1">►</a> 
  <div>
    <iframe width="100%" height="100%" src="адрес_видео" frameborder="0" allowfullscreen></iframe>
  </div>
  Текст
</div>

<a href="#close" title="закрыть">✖</a>
◄ ॥ ►
Текст_3

С помощью CSS анимации можно сделать всевозможные эффекты, скажем такой
<style type="text/css">
.lightbox:target, .video:target {
  -moz-animation: fadeInScale 1.2s ease-in-out;
  -webkit-animation: fadeInScale 1.2s ease-in-out;
  -o-animation: fadeInScale 1.2s ease-in-out;
  -ms-animation: fadeInScale 1.2s ease-in-out;
  animation: fadeInScale 1.2s ease-in-out;
}

@-webkit-keyframes fadeInScale {
  0% { -webkit-transform: scale(10); opacity: 0; }
  100% { -webkit-transform: scale(1); opacity: 1; }
}
@-moz-keyframes fadeInScale {
  0% { -moz-transform: scale(10); opacity: 0; }
  100% { -moz-transform: scale(1); opacity: 1; }
}
@-o-keyframes fadeInScale {
  0% { -o-transform: scale(10); opacity: 0; }
  100% { -o-transform: scale(1); opacity: 1; }
}
@-ms-keyframes fadeInScale {
  0% { -ms-transform: scale(10); opacity: 0; }
  100% { -ms-transform: scale(1); opacity: 1; }
}
@keyframes fadeInScale {
  0% { transform: scale(10); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
</style>
Пример
Анимация позволит и сделать так, чтобы модальное окно открывалось при загрузке страницы спустя какое-то время. Но данный эффект доступен не всем браузерам.
<style type="text/css">
.lightbox {
 position: fixed; top: 0%; left: 0%;
 height: 100%; width: 100%;
 background: rgba(0, 0, 0, 0.6);
 z-index: 100;
 text-align: center;
 visibility: hidden;
 -moz-animation: fadeInScale 1.2s ease-in-out 7s forwards;
 -webkit-animation: fadeInScale 1.2s ease-in-out 7s forwards;
 -o-animation: fadeInScale 1.2s ease-in-out 7s forwards;
 -ms-animation: fadeInScale 1.2s ease-in-out 7s forwards;
 animation: fadeInScale 1.2s ease-in-out 7s forwards;
}

.lightbox > p {
 display: inline-block;
 padding: 8px;
 background: #fff;
 margin-top: 50px;
 text-align: left;
 box-shadow: 0 0 5px #fff;
}

.lightbox img { padding: 0px; }

.lightbox > p > a {
 display: block; 
 text-align:right;
}

@-webkit-keyframes fadeInScale {
  0% { opacity: 0; visibility: visible; }
  100% { opacity: 1; visibility: visible; }
}
@-moz-keyframes fadeInScale {
  0% { opacity: 0; visibility: visible; }
  100% { opacity: 1; visibility: visible; }
}
@-o-keyframes fadeInScale {
  0% { opacity: 0; visibility: visible; }
  100% { opacity: 1; visibility: visible; }
}
@-ms-keyframes fadeInScale {
  0% { opacity: 0; visibility: visible; }
  100% { opacity: 1; visibility: visible; }
}
@keyframes fadeInScale {
  0% { opacity: 0; visibility: visible; }
  100% { opacity: 1; visibility: visible; }
}

.lightbox:target { display: none; }
</style>

<div class="lightbox" id="showimage">
<p>
<a href="#showimage">✖</a><img border="0" src="URL_изо" />
какой-то текст </p>
</div>

Поскольку элемент фиксируется на экране монитора, то прокрутка здесь невозможна. Немного по другому оформим код.
<style type="text/css">
.vkl { cursor: zoom-in; cursor: -moz-zoom-in; cursor: -webkit-zoom-in;}

.lightbox1 {display: none; position:fixed;}

.lightbox1 + div {
  display: none;
  padding: 8px;
  background: #fff;
  box-shadow: 0 0 5px #fff;
  z-index: 101;
  position: relative;}

.lightbox1:target + div {display: inline-block;}

a[href="#close"] {
  position: fixed; top: 0; bottom: 0; right: 0; left: 0;
  z-index: 100;
  cursor: zoom-out; cursor: -moz-zoom-out; cursor: -webkit-zoom-out;
  background: rgba(0, 0, 0, 0.6);
  text-align: right;
  font-size: 200%; 
  padding-right: 7px;
  text-decoration: none;
  color: #cccccc;
  display: none;}

a[href="#close"]:hover {color: #fff;}

.lightbox1:target ~ a[href="#close"], .lightbox1 + div img, .lightbox1 + div iframe {padding: 0px; display: block;}
</style>

<a href="#showimage3" class="vkl">Образец</a>

<br id="showimage3" class="lightbox1"/><div>
  <img alt="Мечты" src="адрес_изо">
  Текст_1
</div>

<a href="#close">✖</a>
Пример
ЛебедьТекст_1
✖
Читать далее - Всплывающее окно при входе на сайт