如何在按钮点击时通过Javascript 更改标签的href
属性值<a/>
?
<script type="text/javascript">
function f1()
{
document.getElementById("abc").href="xyz.php";
}
</script>
<a href="" id="abc">jhg</a>
<a href="" id="" onclick="f1()">jhhghj</a>
Run Code Online (Sandbox Code Playgroud) 嗨,任何人都可以告诉我,我怎么能只做占位符斜体,但当有人在测试盒内写字时,书面文字不应该有斜体.
mycode的:
<input type="text" id="search" placeholder="Search" style="font-style:italic">
Run Code Online (Sandbox Code Playgroud)
我怎么能把斜体放在占位符上而不是整个输入?
如何在元素中的指定索引处插入选项<select multiple>
元素?
谢谢
我有一个CSS选择器,应该在单击标签时显示子内容.选择器沿着input:checked + element + element
给最终元素显示块的行(默认为无).问题是它适用于所有主流浏览器,但webkit除外.Chrome,Safari和Android的移动浏览器(v2.2抱歉,我落后于时代)都无法显示元素.当我检查Chrome中的元素时,它会显示它应该是display: block
但它不会渲染它.我可以取消选中并检查开发人员工具中的属性并显示,但不是之前.
我认为这是webkit中的一个错误.
以下是多部分问题:这是webkit中的已知错误吗?我的选择器出了什么问题吗?我如何解决webkit浏览器的问题(任何创意建议)?
HTML
<input id="c1" type="checkbox">
<label for="c1">Ein</label>
<section>Content</section>
<input id="c2" type="checkbox">
<label for="c2">Zwei</label>
<section>Content</section>
<input id="c3" type="checkbox">
<label for="c3">Drei</label>
<section>Content</section>
Run Code Online (Sandbox Code Playgroud)
CSS
input {
float:left;
clear:left;
visibility: hidden;
position:absolute;
}
label {
color:green;
display:block;
cursor:pointer;
}
section {
display:none;
}
label:after {
content:" +";
}
input:checked + label:after {
content:" -";
}
input:checked + label + section {
display:block;
}
Run Code Online (Sandbox Code Playgroud)
演示:http://jsbin.com/epibin/2
来源:http …
我试图将位于div内的图像居中,然后div位于另一个div内.不用担心,我会发布一些代码,这样你们都可以看到我在这里谈论的内容.
<div id="container">
<div id="featureimage" style="width: 845px">
<img src="Stylesheets/images/globkey.jpg" alt="" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
body {
background-color: #383838;
margin: 0; padding: 0;
font-size: small;
color: #383838;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
* html body {
font-size: x-small; /* for IE5/Win */
font-size: small; /* for other IE versions */
}
img {
border-style: none;
}
/* Conatiner */
#container {
background-color: #fff;
width: 845px;
margin: 0 auto;
overflow: hidden;
}
#featureimage{
width: 620px;
padding: 0 0 0 15px; …
Run Code Online (Sandbox Code Playgroud) 在IE9中看一下这个:
http://jsfiddle.net/dalgard/n6PDB/show/
屏幕转储:
阅读这些评论:
/*
* IE9: Upon moving the mouse a ghostly 1px vertical line appears 53px into the
* blue area - only works with normalized CSS (!?) and not inside an iframe
*/
#test {
width: 152px; /* must be 152px or larger! */
height: 200px; /* can be any height */
border-radius: 1px; /* must be 1px or larger */
background-color: #44f; /* ghost-line becomes invisible with #00f */
}
#test:hover {} /* removing this makes …
Run Code Online (Sandbox Code Playgroud) 我正在制作一个非常简单的html页面,并且想知道如何为我的页面执行以下两项操作:
我写了附加的代码,但容器总是粘在左边,当我调整窗口大小时它不会改变大小.
<title>Demo</title>
<head>This is a demo</head>
<style>
#nav
{
background-color: red;
float: left;
width: 200px;
position:relative;
}
#detail
{
background-color: green;
float : right;
width: 800px;
position:relative;
}
div.testDetail
{
margin-top:10px;
margin-left:20px;
margin-right:20px;
margin-bottom:10px;
}
#container
{
width:1000px;
position:relative;
}
</style>
<hr>
<body>
<div id="container">
<div id="nav">
<ul>Tests</ul>
</div>
<div id="detail">
<div class="testDetail">
<image style="float:right;margin:5px;" src="test1.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test2.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test3.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test4.jpg" width="50px" height="50px"/>
<h3>Title</h3>
<p>Testing</p>
</div>
<hr> …
Run Code Online (Sandbox Code Playgroud) 我有 3 个并排的 Bootstrap 按钮,但其中一个有换行符(我正在用 修改它们white-space: normal
)。我需要它们都具有相同的高度和垂直居中的文本。
我有这样的:
我需要他们这样:
我无法弄清楚如何做到这一点。有任何想法吗?
根据MDN 的new Date()
说法:
创建一个代表单个时间点的 JavaScript Date 实例。日期对象基于时间值,该时间值是自 1970 年 1 月 1 日 UTC 以来的毫秒数
到那个时刻getTime()
:
返回指定日期的数值,作为自 1970 年 1 月 1 日 00:00:00 UTC 以来的毫秒数(之前的时间为负)。
为什么声明:
new Date(new Date(1, 0, 1).setFullYear(1)).getTime();
Run Code Online (Sandbox Code Playgroud)
假设返回从 1970 年 1 月 1 日 00:00:00 UTC 到 01/01/0001 12:00:00 AM 的毫秒数,在不同的机器上给出不同的值,例如-62135600400000
和-62135596800000
? 本地时区(或系统时间?)是否会以某种方式影响此逻辑?
好的,我希望这不是一个简单的疏忽,但我已经在这工作了几个小时!
我正在使用的页面上有一个相当复杂的HTML/CSS结构.我在页面的最底部有一个文本位于底部边距为10px的div中.这个div在另一个底部边缘为10px的div中;.该div在链上的其他div中直到<body>
.
由于某种原因,文本对接在div的底部,它在里面.我为人们创造了一个极简主义的复制品.它确实重现了这个问题,我只是希望我没有删除任何其他有助于解决问题的问题.
我确实让它在最新的镀铬处工作,高度为100%; 在那里的某个地方(我不记得现在在哪里)但它没有解决firefox中的问题,即.这两种浏览器都具有奇怪的css行为,它们最初以正确的底部边距大小显示,但立即向下跳回以使文本再次没有底部边距.这就像一个小小的昙花一现.
哦,也在我的repro html即没有显示任何居中(至少ie9).我希望这不会成为问题.我当然可以轻松地解决这个问题.
在chrome中,如果检查元素,它会突出显示蓝色的文本div,蓝色边界框显示div超出当前显示的位置.
这是极简主义的例子:http://www.del337ed.com/repro.html
我感谢大家的意见/帮助.