0
Q
水印文本css
A
回答
1
我没有看过他们的代码,但是在CSS侧有趣的事情就是在某些情况下,.style.color
设置为灰色。所有这些都是用Javascript完成的。您可以更仔细比我刚才研究它,但基本上是:当箱第一次出现
- 将其设置为灰色的“空白”的文本,当用户类型上的“模糊”如果文本框的文本是空白的(恢复的空白文本和灰色它)内
- 重做#1的字符
- 你可能想要做的#2,当用户点击里面,即焦点事件。
这实际上在Javascript中实现起来非常有趣,你甚至可能会更好地了解你在SO上看到的功能。
2
这里是a simple example使用真实<label>
s,而不是滥用默认值更容易访问。
<!DOCTYPE HTML>
<html>
<head>
<title> Example of having a label that vanishes </title>
<style type="text/css">
/* Basic CSS for use even if JS is not around */
.slim-control {
color: black;
background-color: #aaa;
border: solid black 1px;
padding: 3px;
margin: 3px;
width: 200px;
overflow: hidden; /* Clear fix */
}
.slim-control label {
float: left;
}
.slim-control input {
clear: left;
float: right;
background: #aaa;
color: black;
border: solid 1px black;
width: 150px;
font-size: 1em;
}
/* And if JS is available */
body.js .slim-control {
position: relative;
height: 1em;
}
body.js .slim-control label,
body.js .slim-control input {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 1em;
margin: 0;
padding: 0;
border: 0;
z-index: 2;
}
body.js .slim-control input {
background-color: transparent;
background-color: rgba(100,200,50,.2);
z-index: 3;
}
body.js .slim-control input.non-empty {
background: #aaa;
}
</style>
</head>
<body class="js">
<form action="." method="post">
<div class="slim-control">
<label for="username"> Username </label>
<input name="username" id="username">
</div>
<div class="slim-control">
<label for="password"> Password </label>
<input name="password" id="password" type="password">
</div>
</form>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
(function() {
var nonEmpty = "non-empty";
var inputs = jQuery('.slim-control input');
var setLabelStyle = function setLabelStyle() {
var label = jQuery(this);
if (label.val().length) {
label.addClass(nonEmpty);
} else {
label.removeClass(nonEmpty);
}
};
inputs.focus(function() { jQuery(this).addClass(nonEmpty); });
inputs.blur(setLabelStyle);
inputs.each(setLabelStyle);
}());
</script>
</body>
</html>
相关问题
- 1. 水印CSS不打印
- 2. 从水印文本框
- 3. Silverlight水印文本框?
- 4. 水印文本框在MVC3
- 5. 基于文本的水印?
- 6. 问题水印文本框
- 7. asp.net中的水印文本?
- 8. 如何设置水印文本水印文字
- 9. 对角线重复的水印文本css/html
- 10. 寻找文本框水印的脚本
- 11. 水印嵌入与CSS
- 12. iText展平问题与水印文本
- 13. 如何为文本加水印图像?
- 14. 用于文本框的Javascript“水印”
- 15. 动态更改AJAX水印文本
- 16. 上传图片与水印文本
- 17. 使用javascript的水印文本框
- 18. MVC框架中的水印文本框
- 19. ASP.NET MVC中的水印文本框
- 20. 水印文本位置右下角
- 21. 如何创建水印文本框?
- 22. 水印PDF文件?
- 23. HTML/CSS水平文本包装
- 24. CSS:水平和垂直居中文本?
- 25. CSS:垂直和水平对齐文本?
- 26. 使用CSS水平拉伸文本
- 27. php,gd,创建水印,更改水印文本大小和背景颜色,imagecreatefromjpeg
- 28. 水印的Photoshop脚本?
- 29. 从javascript获取水印绑定文本框的文本值
- 30. 使用html和css创建水印
通常通过简单的'color:#CCCCC'来实现。这不是真正的透明度。 – 2010-05-19 09:25:00
但点击后,风格会再次相同或平常.. 我有onclick更改颜色要求正常.. – Hulk 2010-05-19 09:28:19