Popular Posts
SwiXml - JTextBox (Customized JTextField) LimitedDocument.java package swixml.sample; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import jav... Tick Start tick Java Javascript .net Tick = 0 (GMT+0) 1970/01/01 00:00:00 1970/01/01 00:00:00 1601/01/01 00:00:00... JDateField package bruce.lib.swing; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.A...
Stats
Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts
CSS alpha
.alpha50 {
    filter: alpha(Opacity=50, Style=0); /*for ie*/
    -moz-opacity: 0.5; /* Moz + FF */
    opacity: 0.5; /* CSS3的標準語法,FOR支援CSS3的瀏覽器(FF 1.5)*/
}
Centralize popup div
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <title>Example 7: Vertical alignment of content with JavaScript &amp; CSS</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        <!--
        #content
        {
            position: relative; /* Needed for Safari */
            margin: auto; /* Takes care of horizontal alignment in standards compliant browsers */
            text-align: left;
            width: 200px;
            height: 200px;
            background-color: #fc0;
        }
        h1, p
        {
            margin: 0;
            padding: 1em;
        }
        h1
        {
            font-size: 12px;
            line-height: 1.5em;
        }
        -->
    </style>

    <script type="text/javascript">
        <!--
        function getWindowHeight() {
            var windowHeight = 0;
            if (typeof (window.innerHeight) == 'number') {
                windowHeight = window.innerHeight;
            }
            else {
                if (document.documentElement && document.documentElement.clientHeight) {
                    windowHeight = document.documentElement.clientHeight;
                }
                else {
                    if (document.body && document.body.clientHeight) {
                        windowHeight = document.body.clientHeight;
                    }
                }
            }
            return windowHeight;
        }
        function setContent() {
            if (document.getElementById) {
                var windowHeight = getWindowHeight();
                if (windowHeight > 0) {
                    var contentElement = document.getElementById('content');
                    var contentHeight = contentElement.offsetHeight;
                    if (windowHeight - contentHeight > 0) {
                        contentElement.style.position = 'relative';
                        contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
                    }
                    else {
                        contentElement.style.position = 'static';
                    }
                }
            }
        }
        window.onload = function() {
            setContent();
        }
        window.onresize = function() {
            setContent();
        }
        //-->
    </script>

</head>
<body>
    <div style="position: relative; top: 121.5px;" id="content">
        <h1>
            Content</h1>
        <p>
            This content should be centered in your browser window. CSS is used for horizontal
            alignment, while scripting is used for vertical alignment.</p>
    </div>
</body>
</html>
reference : http://www.alistapart.com/d/footers/footer_variation1.html
function PageViewSize() {
    // initialize
    this.width = 0;
    this.height = 0;
    // determine window height
    function getWindowHeight() {
        var windowHeight = 0;
        if (typeof (window.innerHeight) == "number") {
            windowHeight = window.innerHeight;
        } else {
            if (document.documentElement && document.documentElement.clientHeight) {
                windowHeight = document.documentElement.clientHeight;
            } else {
                if (document.body && document.body.clientHeight) {
                    windowHeight = document.body.clientHeight;
                }
            }
        }
        return windowHeight;
    }
    // determine window width
    function getWindowWidth() {
        var windowWidth = 0;
        if (typeof (window.innerWidth) == "number") {
            windowWidth = window.innerWidth;
        } else {
            if (document.documentElement && document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            } else {
                if (document.body && document.body.clientWidth) {
                    windowWidth = document.body.clientWidth;
                }
            }
        }
        return windowWidth;
    }
    // assign current window size
    this.width = getWindowWidth();
    this.height = getWindowHeight();
    // method to get 'y' location of panel
    this.getTop = function(contentHeight) {
        if (this.height > 0 && this.height - contentHeight > 0) {
            return ((this.height - contentHeight) / 2);
        } else {
            return 0;
        }
    }
    // method to get 'x' location of panel
    this.getLeft = function(contentWidth) {
        if (this.width > 0 && this.width - contentWidth > 0) {
            return ((this.width - contentWidth) / 2);
        } else {
            return 0;
        }
    }
}
i.e. CSS expression
<html>
<style>
p {
border:1px solid red;
max-width:30em;
width:expression( 
    document.body.clientWidth > (500/12) * 
    parseInt(document.body.currentStyle.fontSize)?
        "30em":
        "auto" );
}
</style>
<body>
<p>
[alot of text]
</p>
</body>
</html>
reference : http://www.svendtofte.com/code/max_width_in_ie/
Round corner
border-width: 1px;
border-style: solid;
-moz-border-radius: 11px;
-khtml-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
reference : http://www.wowbox.com.tw/blog/article.asp?id=3148
CSS priority
<html>
<head>
    <title>CSS priority</title>
    <style type="text/css">
    div#divline {
        color : blue !important;  // this will take higher priority for style display
    }
    </style>
</head>
<body>
    <div id="divline" style="color:red;">This is a line set font color red using attribute 'style'.</div>
</body>
</html>
CSS drop shadow
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>CSS drop shadow</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
        #shadow-container
        {
            position: relative;
            left: 3px;
            top: 3px;
            margin-right: 3px;
            margin-bottom: 3px;
        }
        #shadow-container .shadow2, #shadow-container .shadow3, #shadow-container .container
        {
            position: relative;
            left: -1px;
            top: -1px;
        }
        #shadow-container .shadow1
        {
            background: #F1F0F1;
        }
        #shadow-container .shadow2
        {
            background: #DBDADB;
        }
        #shadow-container .shadow3
        {
            background: #B8B6B8;
        }
        #shadow-container .container
        {
            background: #ffffff;
            border: 1px solid #848284;
            padding: 10px;
        }
    </style>
</head>
<body>
    <div id="shadow-container">
        <div class="shadow1">
            <div class="shadow2">
                <div class="shadow3">
                    <div class="container">
                        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                        Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                        unknown printer took a galley of type and scrambled it to make a type specimen book.
                        It has survived not only five centuries, but also the leap into electronic typesetting,
                        remaining essentially unchanged. It was popularised in the 1960s with the release
                        of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
                        publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
CSS in I.E & Firefox
<html>
<head>
    <title>CSS in I.E & Firefox</title>
    <style type="text/css">
    div.LineClass{
        color : red;  /* for firefox */
        @color : blue;  /* for i.e. */
    }
    </style>
</head>
<body>
    <div class="LineClass">Hello world! A simple line using style-sheet.</div>
    <div style="text-decoration:underline;@text-decoration:overline;">Hello world again!</div>
</body>
</html>
note :
The mark @ could be replace with other symbol like + etc.
And the style for I.E. should be placed after the style for Firefox.