2014年12月31日水曜日

jQuery+CSSでウィンドウの表示・非表示を再現してみた。


jQuery+CSSでウィンドウの表示非常時を再現してみた。

以下がイメージ動画。
Window.html


    
        TODO supply a title
        
        
        
        
        
        
    
    
        
        
        
        
ウィンドウのタイトル
コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。 コンテンツの内容はこんな感じですよ。
<!DOCTYPE html> <html>     <head>         <title>TODO supply a title</title>         <meta charset="UTF-8">         <meta name="viewport" content="width=device-width, initial-scale=1.0">         <link rel="stylesheet" href="./css/Window.css">         <script src="./js/vendor/jquery-2.1.1.js"></script>         <script src="./js/vendor/jquery-ui.js"></script>         <script src="./js/Window.js"></script>     </head>     <body>                 <button class="show">ウィンドウを表示</button>                 <div class="window">             <div class="title">                 ウィンドウのタイトル             </div>             <button class="minimize">-</button>             <button class="maximize">□</button>             <button class="close">×</button>             <div class="content">                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                 コンテンツの内容はこんな感じですよ。                             </div>         </div>     </body> </html>


Window.css

.window {

    position:relative;

    width: 260px;

    height: 180px;

    border-style: solid;

    border-width: 2px;

    border-color: rgb(150, 150, 150);

    background: rgb(218, 218, 218);

}



.window > .title {

    position: absolute;

    left: 0px;

    display: inline-block;

    background-color: rgb(0, 0, 230);

    border-color: rgb(0, 0, 180);

    border-width: 2px;

    height: 20px;

    width: 260px;

    margin: 0px;

    color: white;

}



.window > button {

    position: absolute;

    display: inline-block;

    border-width: 2px;

    border-style: solid;

    border-color: rgb(150, 150, 150);

    background-color: rgb(218, 218, 218);

    height: 20px;

    margin: 0px;

}



.window > .minimize {

    right: 40px;

}

.window > .maximize {

    right: 20px;

}

.window > .close {

    right: 0px;

}



.window > .content {

    position: relative;

    display: block;

    overflow: scroll;

    top: 20px;

    width: 260px;

    height: 160px;

}



.show {

    position: relative;

    display: block;

    top: 0px;

    left: 0px;

}



Window.js

$(function(){

   

    var $window = $('.window'),

        $maximize = $window.find('.maximize'),

        $minimize = $window.find('.minimize'),

        $close = $window.find('.close'),

        $title = $window.find('.title'),

        $contents = $window.find('.content'),

        $showButton = $('.show'),

        $baseWindow = $(window);



    $close.on('click', function(){

        $window.css({ display: 'none' });

    });

   



   

    $showButton.on('click', function(){

        $window.css({ display: 'inline-block' });

    });

   

});



0 件のコメント:

コメントを投稿