HTML输入框样式

博客内容涉及HTML输入框的样式设计,探讨了前端开发者如何优化网页输入框的用户体验,同时提到了个人成长和职业规划的话题,以及对中国软件开发工程师面临的问题进行讨论。
昨天做项目,做一个后台登录页,老是感觉输入框不好看,然后就上网搜了一下,看到了这个,确实很好用,兄弟们想美化输入框的,来看看吧!

输入框景背景透明:

<input style="background:transparent;border:1px solid #ffffff">
鼠标划过输入框,输入框背景色变色:
<INPUTvalue="Type here" NAME="user_pass" TYPE="text" SIZE="29"onmouseover="this.style.borderColor='black';this.style.backgroundColor='plum'"
style="width: 106; height: 21"
onmouseout="this.style.borderColor='black';this.style.backgroundColor='#ffffff'" style="border-width:1px;border-color=black">
输入字时输入框边框闪烁(边框为小方型):
<Script Language="JavaScript">
function borderColor(){
if(self['oText'].style.borderColor=='red'){
self['oText'].style.borderColor = 'yellow';
}else{
self['oText'].style.borderColor = 'red';
}
oTime = setTimeout('borderColor()',400);
}
</Script>
<inputtype="text" id="oText" style="border:5px dotted red;color:red"onfocus="borderColor(this);" onblur="clearTimeout(oTime);">
输入字时输入框边框闪烁(边框为虚线):
<style>
#oText{border:1pxdotted #ff0000;ryo:expression(onfocus=function light(){with(document.all.oText){style.borderColor=(style.borderColor=="#ffee00"?"#ff0000":"#ffee00");timer=setTimeout(light,500);}},onblur=function(){this.style.borderColor="#ff0000";clearTimeout(timer)})};
</style>
<input type="text" id="oText">
自动横向廷伸的输入框:
<input type="text" style="huerreson:expression(this.width=this.scrollWidth)" value="abcdefghijk">
自动向下廷伸的文本框:
<textareaname="content" rows="6" cols="80"onpropertychange="if(this.scrollHeight> 80)this.style.posHeight=this.scrollHeight+5">输入几个回车试试</textarea& gt;
只有下划线的文本框:
<input style="border:0;border-bottom:1 solid black;background:;">
软件序列号式的输入框:
<script for="T" event="onkeyup">
if(value.length==3)document.all[event.srcElement.sourceIndex+1].select();
</script>
<inputname="T" size="5" maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T7" size="5" maxlength="3">
软件序列号式的输入框(完整版):
<script for="T"event="onkeyup">if(value.length==maxLength)document.all[event.srcElement.sourceIndex+1].focus();</script>
<script for="T" event="onfocus">select();</script>
<script for="Submit" event="onclick">
var sn=new Array();
for(i=0;i<T.length;i++)
sn=T.value;
alert(sn.join("—"));
</script>
<inputname="T" size="5" maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5"maxlength="3">—<input name="T" size="5" maxlength="3">
<input type="submit" name="Submit">

原文地址: http://bbs.lampbrother.net/read-htm-tid-121706.html
阅读(61) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
### 创建带有增减按钮的输入框样式 为了实现带增减按钮功能的输入框,可以结合 HTML 和 CSS 来完成这一设计目标。下面是一个具体的例子: #### 使用 HTML 结构构建基本框架 通过 `div` 容器包裹两个按钮以及一个用于显示数值的 `input[type="number"]` 输入框。 ```html <div class="quantity"> <button onclick="decrement()">-</button> <input type="number" id="numInput" value="1"/> <button onclick="increment()">+</button> </div> ``` #### 应用 CSS 实现美观效果 利用 CSS 对上述 HTML 元素进行样式化处理,使界面更加友好直观。 ```css .quantity { position: relative; } .quantity button { background-color: #f0f0f0; border: none; height: 30px; width: 30px; cursor: pointer; } .quantity input[type=number] { text-align: center; border: 1px solid #ccc; padding: 7px 0px; border-radius: 3px; padding-left: 5px; appearance: none; /* 移除默认箭头 */ } ``` 此部分CSS借鉴了有关于如何美化HTML文本框的方法[^3]。 #### 添加 JavaScript 功能逻辑 为了让增加减少操作生效,还需要编写简单的JavaScript函数来控制输入框内的值变化。 ```javascript function increment() { var numInput = document.getElementById('numInput'); numInput.value = parseInt(numInput.value) + 1; } function decrement() { var numInput = document.getElementById('numInput'); if (parseInt(numInput.value) > 1) { // 防止小于最小值 numInput.value = parseInt(numInput.value) - 1; } } ``` 这种组合方式不仅实现了所需的功能,同时也保持了良好的用户体验和视觉呈现[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值