zoukankan      html  css  js  c++  java
  • Style对象之一

    <html>
    
        <style type="text/css">
            body{
    
                background-color="#FFCC80";
                background-image:url(0387.jpg);
    
                background-repeat:no-repeat;
            }
    
            p{
                color:white;
    
            }
            div{
    
                border:thin solid green;
                100px;
    
                height:100px;
            }
    
        </style>
    
        <input type="button" onclick="setStyle()" value="变化">
    
        <input type="button" onclick="changeAttachment()" value="图片不动,文字滚动" />
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <p>This is a paragraph</p>
    
        <p>This is a paragraph</p>
        <input type="button" onclick="bgStyle()" value="设置背景颜色">
    
        <input type="button" onclick="imgStyle()" value="添加背景图片">
        <input type="button" onclick="changePosition()" value="改变背景图片的位置" />
    
        <input type="button" onclick="changerepeat()" value="改变背景图片平铺状态" />
        <span id="span1">This is a paragraph</span>
    
        <input type="button" onclick="changeBorder()" value="设置边框" />
        <input type="button" onclick="changeMargin()" value="设置外边距" />
    
        <input type="button" onclick="changeOutline()" value="设置轮廓属性" />
        <input type="button" onclick="changePadding()" value="设置内边距" />
    
        <input type="button" onclick="changedisplay()" value="设置元素是否显示" />
        <input type="button" onclick="changeHeight()" value="设置元素的高" />
    
        <input type="button" onclick="changeWidth()" value="设置元素的宽" />
        <div id="div1">
    
            This is some text. This is some text. This is some text.
            This is some text. This is some text. This is some text.
    
            This is some text. This is some text. This is some text.
        </div>
    
        <input type="button" onclick="hideOverflow()" value="处理不符合元素框的内容" />
        <table border="1" height="100px">
    
              <tr>
                <td id="td1">
    
                Some example text
                </td>
    
              </tr>
        </table>
    
        <input type="button" onclick="alignText()" value="设置内容在元素框中的垂直对齐方式" />
        
        <input type="button" onclick="changeVisibility()" value="设置元素是否可见" />
    
        <script>
            //Style 对象
    
            //Background 属性
            //background 属性在一个声明中设置所有的背景属性
    
            /*function setStyle(){
                document.body.style.background="#FFCC80 url(0387.jpg) no-repeat";
    
            }
            //backgroundAttachment 属性设置背景图像是否固定或者随着页面的其余部分滚动
    
            //实现了图片不动,文字滚动
            //scroll  图片和文字一起滚动
    
            //fixed    图片不动,文字滚动
            function changeAttachment(){
    
                document.body.style.backgroundAttachment="fixed";
            }
    
            //backgroundColor 属性设置元素的背景颜色
    
            function bgStyle(){
                document.body.style.backgroundColor = "#FFCC80";
                
            }
    
            //backgroundImage 属性设置元素的背景图像
    
            function imgStyle(){
                document.body.style.backgroundImage = "url(./0387.jpg)"
    
            }
           
            //backgroundPosition 属性设置背景图像的位置
    
            //backgroundPositionX 属性设置背景图像左右的位置
            //backgroundPositionX 属性设置背景图像上下的位置
    
            //top left            上 左
            //top center        上 左右居中
    
            //top right            上 右
            //center left        上下居中 左
    
            //center center        上下居中 左右居中   
            //center right        上下居中 右
    
            //bottom left        下    左
            //bottom center        下 左右居中
    
            //bottom right        下 右
            //如果您仅规定了一个关键词,那么第二个值将是"center"。默认值:0% 0%。
    
            function changePosition(){
                document.body.style.backgroundPosition="center center";
    
            }
           
            //backgroundRepeat 属性设置背景图像是否及如何重复。
    
            //repeat 默认。背景图像将在垂直方向和水平方向重复。
            //repeat-x 背景图像将在水平方向重复。
    
            //repeat-y 背景图像将在垂直方向重复。
            //no-repeat 背景图像将仅显示一次。
    
            function changerepeat(){
                document.body.style.backgroundRepeat="repeat-x";
            }
    
            //Border 和 Margin 属性
    
            //border 属性在一个声明中设置所有边框属性
            //第一个参数是设置边框的宽度
    
            //第二个参数是设置边框的样式
            //第三个参数是设置边框的颜色
    
            function changeBorder(){
    
                document.getElementById("span1").style.border="1px solid #0000FF";
            }
            
            //borderWidth        边框的宽度
    
            //borderStyle        边框的样式
            //borderColor        边框的颜色
    
            //borderTop            设置上边框
            //borderTopWidth    上边框的宽度
    
            //borderTopStyle    上边框的样式
            //borderTopColor    上边框的颜色
    
            //borderBottom        设置下边框
            //borderBottomWidth    下边框的宽度
    
            //borderBottomStyle    下边框的样式
            //borderBottomColor    下边框的颜色
    
            //borderLeft        设置左边框
            //borderLeftWidth    左边框的宽度
    
            //borderLeftStyle    左边框的样式
            //borderLeftColor    左边框的颜色
    
            //borderRight        设置右边框
            //borderRightWidth    右边框的宽度
    
            //borderRightStyle    右边框的样式
            //borderRightColor    右边框的颜色
    
            //margin 属性设置元素的外边距
    
            //如果规定一个值,比如 div {margin: 50px} - 所有的外边距都是 50 px
            //如果规定两个值,比如 div {margin: 50px 10px} - 上下外边距是 50px,左右外边距是 10 px。
    
            //如果规定三个值,比如 div {margin: 50px 10px 20px}- 上外边距是 50 px,而左右外边距是 10 px,下外边距是 20 px。
            //2013/8/14如果规定四个值,比如 div {margin: 50px 10px 20px 30px} - 上外边距是 50 px,右外边距是 10 px,下外边距是 20 px,左外边距是 30 px。
    
            function changeMargin(){
                document.getElementById("span1").style.margin="100px";
    
            }
            //marginTop            设置元素的上边距
    
            //marginBottom        设置元素的下边距
            //marginLeft        设置元素的左边距
    
            //marginRight        设置元素的右边距
    
            //outline 属性在一个声明中设置所有轮廓属性
    
            function changeOutline(){
                document.getElementById("span1").style.outline="5px dotted #0000FF";
    
            }
            //outlineColor        //设置围绕元素的轮廓颜色
    
            //outlineStyle        //设置围绕元素的轮廓样式
            //outlineWidth        //设置围绕元素的轮廓宽度
    
            //padding 属性设置元素的内边距
    
            function changePadding(){
                document.getElementById("span1").style.padding="5px";
    
            }
            //paddingTop        //设置元素的上填充
    
            //paddingBottom        //设置元素的下填充
    
            //paddingLeft        //设置元素的左填充
            //paddingRight        //设置元素的右填充
    
            //Layout 属性
    
            //display属性设置元素如何显示
            //none 此元素不会被显示。
    
            //block 此元素将显示为块级元素,此元素前后会带有换行符。
            //inline 默认。此元素会被显示为内联元素,元素前后没有换行符。
    
            //list-item 此元素会作为列表显示。
            //run-in 此元素会根据上下文作为块级元素或内联元素显示。
    
            //compact 此元素会根据上下文作为块级元素或内联元素显示。
            //marker  
    
            //table 此元素会作为块级表格来显示(类似 <table>),表格前后带有换行符。
            //inline-table 此元素会作为内联表格来显示(类似 <table>),表格前后没有换行符。
    
            //table-row-group 此元素会作为一个或多个行的分组来显示(类似 <tbody>)。
            //table-header-group 此元素会作为一个或多个行的分组来显示(类似 <thead>)。
    
            //table-footer-group 此元素会作为一个或多个行的分组来显示(类似 <tfoot>)。
            //table-row 此元素会作为一个表格行显示(类似 <tr>)。
    
            //table-column-group 此元素会作为一个或多个列的分组来显示(类似 <colgroup>)。
            //table-column  此元素会作为一个单元格列显示(类似 <col>)
    
            //table-cell 此元素会作为一个表格单元格显示(类似 <td> 和 <th>)
            //table-caption 此元素会作为一个表格标题显示(类似 <caption>)
    
            function changedisplay(){
                document.getElementById("span1").style.display="none";
    
            }
    
           
            //height 属性设置元素的高度
    
            function changeHeight(){
                document.getElementById("span1").style.height="100px";
    
            }
    
            //height 属性设置元素的高度
    
            function changeWidth(){
                document.getElementById("span1").style.width="100px";
    
            }
           
            //maxHeight        设置元素的最大高度
    
            //maxWidth        设置元素的最大宽度
            //minHeight        设置元素的最小高度
    
            //minWidth        设置元素的最小宽度
    
            //overflow 属性规定如何处理不符合元素框的内容
    
            //visible 内容不会被修剪,会呈现在元素框之外。
            //hidden 内容会被修剪,但是浏览器不会显示供查看内容的滚动条。
    
            //scroll 内容会被修剪,但是浏览器会显示滚动条以便查看其余的内容。
            //auto 由浏览器决定如何显示。如果需要,则显示滚动条。
    
            function hideOverflow(){
                document.getElementById("div1").style.overflow="hidden";
    
            }
    
            //verticalAlign 属性设置内容在元素框中的垂直对齐方式
    
            //baseline 默认。元素放置在父元素的基线上。
            //sub 垂直对齐文本的下标。
    
            //super 垂直对齐文本的上标
            //top 把元素的顶端与行中最高元素的顶端对齐
    
            //text-top 把元素的顶端与父元素字体的顶端对齐
            //middle 把此元素放置在父元素的中部。
    
            //bottom 把元素的顶端与行中最低的元素的顶端对齐。
            //text-bottom 把元素的底端与父元素字体的底端对齐。
    
            //length  
            //% 使用 "line-height" 属性的百分比值来排列此元素。允许使用负值。
    
            function alignText(){
                document.getElementById("td1").style.verticalAlign="top";
    
            }
           
            //visibility 属性设置元素是否可见
    
            //visible 默认。元素框是可见的。
            //hidden 元素框不可见,但仍然影响布局。
    
            function changeVisibility(){
                document.getElementById("span1").style.visibility="hidden";
    
            }
    
    */
    
        </script>
    </html>



  • 相关阅读:
    Spring Boot 中加载XML配置
    C#winfrom打开指定的文件
    C#怎么实现文件下载功能的四种方法
    C#查看已下载文件大小和扩展名
    C#winfrom文件下载到本地
    判断DataGridView是否选中某行
    Secure CRT注册码
    http-server 开启服
    学习网址
    angular中table表格组件的使用
  • 原文地址:https://www.cnblogs.com/james1207/p/3260663.html
Copyright © 2011-2022 走看看