LoginSignup
1
1

More than 5 years have passed since last update.

サイド固定バナー(マイカートボタンなど)

Last updated at Posted at 2017-09-30

CSS

test.css
@media screen and (min-width: 400px /*表示させたくない最小の大きさを記入(これはスマホの画面の大きさ)*/){
#sidebanner a{ display: none;}
}
#sidebanner a{
display: block;
background: url("画像URL")/*通常時画像*/ no-repeat scroll 0 0;
width: 50px;/*画像幅*/
height: 150px;/*画像高さ*/
text-indent:-9999px;
position:fixed;
right:0px;
top:140px;
}

#sidebanner a:hover{
display: block;
background: url("画像URL")/*マウスオーバー時画像*/ no-repeat scroll 0 0;
width: 50px;/*画像幅*/
height: 150px;/*画像高さ*/
text-indent:-9999px;
position:fixed;
right:0px;
top:140px;
-webkit-transition: width ease-in-out 0.5s;/*マウスオーバーの動く時間を記入して滑らかさを調節*/
-moz-transition: width ease-in-out 0.5s;
-ms-transition: width ease-in-out 0.5s;
-o-transition: width ease-in-out 0.5s;
transition: width ease-in-out 0.5s;
}

HTML

test.html
<div id="sidebanner">
<a href="リンク先URL"></a>
</div>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1