html中一些界面设计

1.使用表格整行作为可点击跳转
HTML:

<tbody>
    <tr class="tr-link" onclick="window.document.location = 'http:\\www.cnblog.com\zyx1314'">
        <td>1td>
        <td>forevertd>
        <td>enjoytd>
    tr>
tbody>

CSS:

.tr-link:hover { cursor: pointer; }

2.HTML CSS样式用户留言表单
HTML:


<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
    <link rel="stylesheet" type="text/css" href="css/addJob.css">
head>
<body>
<form action="" method="post" class="elegant-aero">
    <h1>发布招聘
        <span>请填写您的招聘需求span>
    h1>
<label>
    <span>岗位 :span>
    <input id="jobname" type="text" name="jobname" placeholder="Your Full Name" />
label>
<label>
    <span>Your Email :span>
    <input id="email" type="email" name="email" placeholder="Valid Email Address" />
label>
<label>
    <span>Message :span>
    <textarea id="message" name="message" placeholder="Your Message to Us">textarea>
label>
<label>
    <span>Subject :span><select name="selection">
    <option value="Job Inquiry">Job Inquiryoption>
    <option value="General Question">General Questionoption>
select>
label>
<label>

    <input type="button" class="button" value="Send" />
label>
form>
body>
html>

CSS:

.elegant-aero {
    margin-left:auto;
    margin-right:auto;
    max-width: 500px;
    background: #D2E9FF;
    padding: 20px 20px 20px 20px;
    font: 12px Arial, Helvetica, sans-serif;
    color: #666;
}
.elegant-aero h1 {
    font: 24px "Trebuchet MS", Arial, Helvetica, sans-serif;
    padding: 10px 10px 10px 20px;
    display: block;
    background: #C0E1FF;
    border-bottom: 1px solid #B8DDFF;
    margin: -20px -20px 15px;
}
.elegant-aero h1>span {
    display: block;
    font-size: 11px;
}
.elegant-aero label>span {
    float: left;
    margin-top: 10px;
    color: #5E5E5E;
}
.elegant-aero label {
    display: block;
    margin: 0px 0px 5px;
}
.elegant-aero label>span {
    float: left;
    width: 20%;
    text-align: right;
    padding-right: 15px;
    margin-top: 10px;
    font-weight: bold;
}
.elegant-aero input[type="text"], .elegant-aero input[type="email"], .elegant-aerotextarea, .elegant-aero select {
    color: #888;
    width: 70%;
    padding: 0px 0px 0px 5px;
    border: 1px solid #C5E2FF;
    background: #FBFBFB;
    outline: 0;
    -webkit-box-shadow:inset 0px 1px 6px #ECF3F5;
    box-shadow: inset 0px 1px 6px #ECF3F5;
    font: 200 12px/25px Arial, Helvetica, sans-serif;
    height: 30px;
    line-height:15px;
    margin: 2px 6px 16px 0px;
}
.elegant-aero textarea{
    height:100px;
    padding: 5px 0px 0px 5px;
    width: 70%;
}
.elegant-aero select {
    background: #fbfbfb url('down-arrow.png') no-repeat right;
    background: #fbfbfb url('down-arrow.png') no-repeat right;
    appearance:none;
    -webkit-appearance:none;
    -moz-appearance: none;
    text-indent: 0.01px;
    text-overflow: '';
    width: 70%;
}
.elegant-aero .button{
    padding: 10px 30px 10px 30px;
    background: #66C1E4;
    border: none;
    color: #FFF;
    box-shadow: 1px 1px 1px #4C6E91;
    -webkit-box-shadow: 1px 1px 1px #4C6E91;
    -moz-box-shadow: 1px 1px 1px #4C6E91;
    text-shadow: 1px 1px 1px #5079A3;
}
.elegant-aero .button:hover{
    background: #3EB1DD;
}

效果图:
html中一些界面设计_第1张图片

3.下拉框联动(省份+城市)
最终的效果是选择省份,在city控件中自动显示该省份下的城市.

html代码:
<select id="province" runat="server" onchange="selectprovince(this);" style=" width:95px;">select>
<select id="city" runat="server" style=" width:95px;">select>

-----------------------

javascript代码:

<script type="text/javascript">
    var list1 = new Array;
    var list2 = new Array;
    list1[list1.length] = "北京市";
    list1[list1.length] = "天津市";
    list1[list1.length] = "河北省";
    list1[list1.length] = "山西省";
    list1[list1.length] = "内蒙古";
    list1[list1.length] = "辽宁省";
    list1[list1.length] = "吉林省";
    list1[list1.length] = "黑龙江省";
    list1[list1.length] = "上海市";
    list1[list1.length] = "江苏省";
    list1[list1.length] = "浙江省";
    list1[list1.length] = "安徽省";
    list1[list1.length] = "福建省";
    list1[list1.length] = "江西省";
    list1[list1.length] = "山东省";
    list1[list1.length] = "河南省";
    list1[list1.length] = "湖北省";
    list1[list1.length] = "湖南省";
    list1[list1.length] = "广东省";
    list1[list1.length] = "广西自治区";
    list1[list1.length] = "海南省";
    list1[list1.length] = "重庆市";
    list1[list1.length] = "四川省";
    list1[list1.length] = "贵州省";
    list1[list1.length] = "云南省";
    list1[list1.length] = "西藏自治区";
    list1[list1.length] = "陕西省";
    list1[list1.length] = "甘肃省";
    list1[list1.length] = "青海省";
    list1[list1.length] = "宁夏回族自治区";
    list1[list1.length] = "新疆维吾尔自治区";
    list1[list1.length] = "香港特别行政区";
    list1[list1.length] = "澳门特别行政区";
    list1[list1.length] = "台湾省";
    list1[list1.length] = "其它";

    list2[list2.length] = new Array("北京", "东城区", "西城区", "崇文区", "宣武区", "朝阳区", "丰台区", "石景山区", " 海淀区(中关村)", "门头沟区", "房山区", "通州区", "顺义区", "昌平区", "大兴区", "怀柔区", "平谷区", "密云县", "延庆县", " 其他");
    list2[list2.length] = new Array("和平区", "河东区", "河西区", "南开区", "红桥区", "塘沽区", "汉沽区", "大港区",
                "西青区", "津南区", "武清区", "蓟县", "宁河县", "静海县", "其他");
    list2[list2.length] = new Array("石家庄市", "张家口市", "承德市", "秦皇岛市", "唐山市", "廊坊市", "衡水市",
                "沧州市", "邢台市", "邯郸市", "保定市", "其他");
    list2[list2.length] = new Array("太原市", "朔州市", "大同市", "长治市", "晋城市", "忻州市", "晋中市", "临汾市",
                "吕梁市", "运城市", "其他");
    list2[list2.length] = new Array("呼和浩特市", "包头市", "赤峰市", "呼伦贝尔市", "鄂尔多斯市", "乌兰察布市",
                "巴彦淖尔市", "兴安盟", "阿拉善盟", "锡林郭勒盟", "其他");
    list2[list2.length] = new Array("沈阳市", "朝阳市", "阜新市", "铁岭市", "抚顺市", "丹东市", "本溪市", "辽阳市",
                "鞍山市", "大连市", "营口市", "盘锦市", "锦州市", "葫芦岛市", "其他");
    list2[list2.length] = new Array("长春市", "白城市", "吉林市", "四平市", "辽源市", "通化市", "白山市", "延边朝鲜族自治州", "其他");
    list2[list2.length] = new Array("哈尔滨市", "七台河市", "黑河市", "大庆市", "齐齐哈尔市", "伊春市", "佳木斯市",
                "双鸭山市", "鸡西市", "大兴安岭地区(加格达奇)", "牡丹江", "鹤岗市", "绥化市 ", "其他");
    list2[list2.length] = new Array("黄浦区", "卢湾区", "徐汇区", "长宁区", "静安区", "普陀区", "闸北区", "虹口区",
                "杨浦区", "闵行区", "宝山区", "嘉定区", "浦东新区", "金山区", "松江区", "青浦区", "南汇区", "奉贤区", "崇明县", "其他");
    list2[list2.length] = new Array("南京市", "徐州市", "连云港市", "宿迁市", "淮安市", "盐城市", "扬州市", "泰州市",
                "南通市", "镇江市", "常州市", "无锡市", "苏州市", "其他");
    list2[list2.length] = new Array("杭州市", "湖州市", "嘉兴市", "舟山市", "宁波市", "绍兴市", "衢州市", "金华市",
                "台州市", "温州市", "丽水市", "其他");
    list2[list2.length] = new Array("合肥市", "宿州市", "淮北市", "亳州市", "阜阳市", "蚌埠市", "淮南市", "滁州市",
                "马鞍山市", "芜湖市", "铜陵市", "安庆市", "黄山市", "六安市", "巢湖市", "池州市", "宣城市", "其他");
    list2[list2.length] = new Array("福州市", "南平市", "莆田市", "三明市", "泉州市", "厦门市", "漳州市", "龙岩市", "宁德市", "其他");
    list2[list2.length] = new Array("南昌市", "九江市", "景德镇市", "鹰潭市", "新余市", "萍乡市", "赣州市", "上饶市",
                "抚州市", "宜春市", "吉安市", "其他");
    list2[list2.length] = new Array("济南市", "聊城市", "德州市", "东营市", "淄博市", "潍坊市", "烟台市", "威海市",
                "青岛市", "日照市", "临沂市", "枣庄市", "济宁市", "泰安市", "莱芜市", "滨州市", "菏泽市", "其他");
    list2[list2.length] = new Array("郑州市", "三门峡市", "洛阳市", "焦作市", "新乡市", "鹤壁市", "安阳市", "濮阳市",
                "开封市", "商丘市", "许昌市", "漯河市", "平顶山市", "南阳市", "信阳市", "周口市", "驻马店市", "其他");
    list2[list2.length] = new Array("武汉市", "十堰市", "襄樊市", "荆门市", "孝感市", "黄冈市", "鄂州市", "黄石市",
                "咸宁市", "荆州市", "宜昌市", "随州市", "恩施土家族苗族自治州", "仙桃市", "天门市", "潜江市", "神农架林区", "其他");
    list2[list2.length] = new Array("长沙市", "张家界市", "常德市", "益阳市", "岳阳市", "株洲市", "湘潭市", "衡阳市",
                "郴州市", "永州市", "邵阳市", "怀化市", "娄底市", "湘西土家族苗族自治州", "其他");
    list2[list2.length] = new Array("广州市", "清远市市", "韶关市", "河源市", "梅州市", "潮州市", "汕头市", "揭阳市",
                "汕尾市", " 惠州市", "东莞市", "深圳市", "珠海市", "中山市", "江门市", "佛山市", "肇庆市", "云浮市",
                "阳江市", "茂名市", "湛江市", " 其他");
    list2[list2.length] = new Array("南宁市", "桂林市", "柳州市", "梧州市", "贵港市", "玉林市", "钦州市", "北海市",
                "防城港市", "崇左市", "百色市", "河池市", "来宾市", "贺州市", "其他");
    list2[list2.length] = new Array("海口市", "三亚市", "其他");
    list2[list2.length] = new Array("渝中区", "大渡口区", "江北区", "沙坪坝区", "九龙坡区", "南岸区", "北碚区",
                "万盛区", "双桥区", "渝北区", "巴南区", "万州区", "涪陵区", "黔江区", "长寿区", "合川市", "永川市",
                "江津市", "南川市", "綦江县", "潼南县", "铜梁县", "大足县", "璧山县", "垫江县", "武隆县", "丰都县",
                "城口县", "开县", "巫溪县", "巫山县", "奉节县", "云阳县", "忠县", "石柱土家族自治县", "彭水苗族土家族自治县",
                "酉阳土家族苗族自治县", "秀山土家族苗族自治县", "其他");
    list2[list2.length] = new Array("成都市", "广元市", "绵阳市", "德阳市", "南充市", "广安市", "遂宁市",
                "内江市", "乐山市", "自贡市", "泸州市", "宜宾市", "攀枝花市", "巴中市", "资阳市", "眉山市", "雅安",
                "阿坝藏族羌族自治州", "甘孜藏族自治州", "凉山彝族自治州县", "其他");
    list2[list2.length] = new Array("贵阳市", "六盘水市", "遵义市", "安顺市", "毕节地区", "铜仁地区",
                "黔东南苗族侗族自治州", "黔南布依族苗族自治州", "黔西南布依族苗族自治州", "其他");
    list2[list2.length] = new Array("昆明市", "曲靖市", "玉溪市", "保山市", "昭通市", "丽江市", "普洱市",
                "临沧市", "宁德市", "德宏傣族景颇族自治州", "怒江傈僳族自治州", "楚雄彝族自治州", "红河哈尼族彝族自治州",
                "文山壮族苗族自治州", "大理白族自治州", "迪庆藏族自治州", "西双版纳傣族自治州", "其他");
    list2[list2.length] = new Array("拉萨市", "那曲地区", "昌都地区", "林芝地区", "山南地区", "日喀则地区", "阿里地区", "其他");
    list2[list2.length] = new Array("西安市", "延安市", "铜川市", "渭南市", "咸阳市", "宝鸡市", "汉中市", "安康市", "商洛市", "其他");
    list2[list2.length] = new Array("兰州市 ", "嘉峪关市", "金昌市", "白银市", "天水市", "武威市", "酒泉市",
                "张掖市", "庆阳市", "平凉市", "定西市", "陇南市", "临夏回族自治州", "甘南藏族自治州", "其他");
    list2[list2.length] = new Array("西宁市", "海东地区", "海北藏族自治州", "黄南藏族自治州", "玉树藏族自治州",
                "海南藏族自治州", "果洛藏族自治州", "海西蒙古族藏族自治州", "其他");
    list2[list2.length] = new Array("银川市", "石嘴山市", "吴忠市", "固原市", "中卫市", "其他");
    list2[list2.length] = new Array("乌鲁木齐市", "克拉玛依市", "喀什地区", "阿克苏地区", "和田地区", "吐鲁番地区",
                "哈密地区", "塔城地区", "阿勒泰地区", "克孜勒苏柯尔克孜自治州", "博尔塔拉蒙古自治州",
                "昌吉回族自治州伊犁哈萨克自治州", "巴音郭楞蒙古自治州", "河子市", "阿拉尔市", "五家渠市", "图木舒克市", "其他");
    list2[list2.length] = new Array("香港", "其他");
    list2[list2.length] = new Array("澳门", "其他");
    list2[list2.length] = new Array("台湾", "其他");

    var ddlProvince = document.getElementById("province");
    var ddlCity = document.getElementById("city");
    for(var i =0;ivar option = document.createElement("option");
        option.appendChild(document.createTextNode(list1[i]));
        option.value = list1[i];
        ddlProvince.appendChild(option);
        //city initialize
        var firstprovince = list2[0];
        for (var j = 0; j < firstprovince.length; j++) {
            var optioncity = document.createElement("option");
            optioncity.appendChild(document.createTextNode(firstprovince[j]));
            optioncity.value = firstprovince[j];
            ddlCity.appendChild(optioncity);
        }
    }
    function indexof(obj,value)
    {
        var k=0;
        for(;kif(obj[k] == value)
            return k;
        }
        return k;
    }
    function selectprovince(obj) {
        ddlCity.options.length = 0;//clear
        var index = indexof(list1,obj.value);
        var list2element = list2[index];
        for(var i =0;ivar option = document.createElement("option");
            option.appendChild(document.createTextNode(list2element[i]));
            option.value = list2element[i];
            ddlCity.appendChild(option);
        }
    }
script>

4.下拉框联动(年月日)
html:

<label>
        <span>截止时间 :span>
        <td><select id="year" onchange="setDay()" style=" width:95px;">
        <option value="">option>

    select> <select id=month" onchange="setDay()" style=" width:95px;">
        <option value="">option>

    select> <select id="day" style=" width:95px;">
        <option value="">option>

    select>td>
    label>

js:

 <script type="text/javascript">
    //把年份加载进去
    var year = document.getElementById("year");
    for(var i = 2017 ; i <=2020 ; i ++){
    var options = document.createElement("option");
    options.innerHTML = i;
    year.appendChild(options);
    }
    script>

    <script type="text/javascript">
    //把月份加载进去
    var month = document.getElementById("month");
    for(var i = 1 ; i <=12 ; i ++){
        var options = document.createElement("option");
        options.innerHTML = i;
        month.appendChild(options);
    }
    script>
    <script type="text/javascript">
        //把天数加载进去
        var day = document.getElementById("day");
        for(var i = 1 ; i <=31 ; i ++){
            var options = document.createElement("option");
            options.innerHTML = i;
            day.appendChild(options);
        }
    script>



    <script type="text/javascript">

        //根据年份,判断该月的具体天数,分为闰年
        function setDay(){
            var specialyear ; //闰年的容器

            var year = document.getElementById("year");
            var yearIndex = year.selectedIndex;//获取选择年份的位置
            var yearSelect = year.options[yearIndex].text;//获取具体的年份
            if((yearSelect%4==0 && yearSelect%100!=0) || yearSelect%400==0)
                specialyear=yearSelect;//记下闰年
            // alert(specialyear);

            //获取选择的月份
            var month = document.getElementById("month");
            var monthIndex = month.selectedIndex;
            var monthSelect = month.options[monthIndex].text;
            // alert(monthSelect);

            //加载天数
            var day = document.getElementById("day");
            day.options.length=0;
            //alert(monthSelect);
            if(monthSelect=='1'||monthSelect=='3'||monthSelect=='5'||monthSelect=='7'||monthSelect=='8'||monthSelect=='10'||monthSelect=='12'){//这里数字要加引号
                for(var i = 1 ; i <=31 ; i ++){
                    var options = document.createElement("option");
                    options.innerHTML = i ;
                    day.appendChild(options);
                }
            }
            // alert("day22");
            if(monthSelect=='2'||monthSelect=='4'||monthSelect=='6'||monthSelect=='9'&&monthSelect=='11'){
                if(yearSelect==specialyear && monthSelect=='2') {
                    for(var i = 1 ; i <=28 ; i ++){
                        var options = document.createElement("option");
                        options.innerHTML = i ;
                        day.appendChild(options);
                    }
                } else{
                    for(var i = 1 ; i <=30 ; i ++){
                        var options = document.createElement("option");
                        options.innerHTML = i ;
                        day.appendChild(options);
                    }
                }
            }
        }
    script>

5.点击文本框,下方出现选择框,选项数据返回到文本框中。
html:


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body{font-size:12px;}
        .selectItemcont{padding:8px;}
        #selectItem{background:#FFF;position:absolute;top:0px;left:center;border:1px solid #000;overflow:hidden;width:240px;z-index:1000;}
        .selectItemtit{line-height:20px;height:20px;margin:1px;padding-left:12px;}
        .bgc_ccc{background:#E88E22;}
        .selectItemleft{float:left;margin:0px;padding:0px;font-size:12px;font-weight:bold;color:#fff;}
        .selectItemright{float:right;cursor:pointer;color:#fff;}
        .selectItemhidden{display:none;}
    style>
    <script src="../public/jquery-1.3.1.js" type="text/javascript">script>
    <script type="text/javascript" src="../public/jquery.bgiframe.js">script>
    <script>

        jQuery.fn.selectCity = function(targetId) {
            var _seft = this;
            var targetId = $(targetId);

            this.click(function(){
                var A_top = $(this).offset().top + $(this).outerHeight(true);  //  1
                var A_left =  $(this).offset().left;
                targetId.bgiframe();
                targetId.show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px"});
            });

            targetId.find("#selectItemClose").click(function(){
                targetId.hide();
            });

            targetId.find("#selectSub :checkbox").click(function(){
                targetId.find(":checkbox").attr("checked",false);
                $(this).attr("checked",true);
                _seft.val( $(this).val() );
                targetId.hide();
            });

            $(document).click(function(event){
                if(event.target.id!=_seft.selector.substring(1)){
                    targetId.hide();
                }
            });

            targetId.click(function(e){
                e.stopPropagation(); //  2
            });

            return this;
        }

        $(function(){
            //test1:
            $("#address").selectCity("#selectItem");
        });
    script>
head>
<body>
<br/>

地址选择一:<br/>
<input type="text" name="address" id="address" >
<br/><br/>
<br/><br/><br/>

<div id="selectItem" class="selectItemhidden">
    <div id="selectItemAd" class="selectItemtit bgc_ccc">
        <h2 id="selectItemTitle" class="selectItemleft">请选择城市h2>
        <div id="selectItemClose" class="selectItemright">关闭div>
    div>
    <div id="selectItemCount" class="selectItemcont">
        <div id="selectSub">
            <input type="checkbox" name="cr01"  id="cr01" value="北京1"/><label for="cr01">北京1label>
            <input type="checkbox" name="cr02"  id="cr02" value="北京2"/><label for="cr02">北京2label>
            <input type="checkbox" name="cr03"  id="cr03" value="北京3"/><label for="cr03">北京3label>
            <input type="checkbox" name="cr09"  id="cr09" value="北京4"/><label for="cr09">北京4label>
        div>
    div>
div>
body>
html>

jquery.bgiframe.js:

(function($){
$.fn.bgIframe = $.fn.bgiframe = function(s) {
    // This is only for IE6
    if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
        s = $.extend({
            top     : 'auto', // auto == .currentStyle.borderTopWidth
            left    : 'auto', // auto == .currentStyle.borderLeftWidth
            width   : 'auto', // auto == offsetWidth
            height  : 'auto', // auto == offsetHeight
            opacity : true,
            src     : 'javascript:false;'
        }, s || {});
        var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
            html = '