搜索框css样式

html-css07

搜索框css样式,第1张

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="

<head>

<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

<title>无标题文档</title>

<script type="text/javascript" src="jquery.js"></script>

<style>

.{ padding:0 margin:0 list-style:none}

.htmlBox{ width:100% min-width:500px height:500px border:1px solid #A349A4 border-radius:5px}

.sskBox{ width:100% height:35px margin-top:150px border:1px solid #000 border-left:0 border-right:0}

.zc{ width:100px height:35px float:left}

.zj{ width:250px height:35px float:left border-left:1px solid #000 border-right:1px solid #000}

.yc{ height:35px float:right}

</style>

</head>

<body>

<div class="htmlBox">

 <div class="sskBox">

 <div class="zc">左边100</div>

 <div class="zj">中间250</div>

 <div class="yc">右边自适应</div>

</div>

</div>

</body>

<script>

tmntH()//加载的时候执行一次

$(window).resize(function() {tmntH()})//浏览器窗口变化时执行

function tmntH()

{

    var ycw=$(".sskBox").width()-352+'px'//yc的宽度等于sskBox宽度-350-2(边框线)

    //alert(div3)

    $(".yc").css("width",ycw)

    

}

</script>

</body>

</html>

是不是要这种浮动效果?定位很简单的,主要是:position 这个。一种是绝对定位,相对于浏览器窗口进行定位,如下:

<div class="heaader"><img src="https://www.poscom.cn/static/image/default/logo-2.png" alt="www.poscom.cn"/></div>

<style>

.header {

    background-color: #3454d1

    height: 60px

    position: relative

    z-index: 199

    position: fixed

    width: 100%

    top: 0

}

</style>

一种是相对定位,相对于相对定位的元素

<div class="relative">

   <div class="absolute"><img src="https://www.poscom.cn/static/image/default/logo-2.png" alt="www.poscom.cn"/></div></div>

<style>

.relative{

    background-color: #3454d1

    height: 100px

    position: relative

    width: 100%

}

.absolute{

    position:absolute

    left:10pxtop:10px}

</style>

昂,需要把背景图片定位截取出来,不过网上有方法,你可以去搜索下

三种方法,具体解释,你可以去网上搜索一下,它会比我解释的更详细

div{ background:#FFF url(image) no-repeat top left}

div{ background:#FFF url(image) no-repeat 23px -23px}

background:#FFF url(image) no-repeat 50% 30%