如何修改此代码以在低于10的任何数字之前添加0
$('#detect').html( toGeo(apX, screenX) + latT +', '+ toGeo(apY, screenY) + lonT );
function toGeo(d, max) {
var c = '';
var r = d/max * 180;
var deg = Math.floor(r);
c += deg + "° ";
r = (r - deg) * 60;
var min = Math.floor(r);
c += min + "? ";
r = (r - min) * 60;
var sec = Math.floor(r);
c += sec + "?";
return c;
}
Run Code Online (Sandbox Code Playgroud)
因此,输出将改变
4°7'34"W,168°1'23"N
至
04°07'34"W,168°01'23"N
谢谢你的时间
我应该疯了吗?
.project.work:first-child:before {
content: 'Projects';
}
.project.research:first-child:before {
content: 'Research';
}
Run Code Online (Sandbox Code Playgroud)
<div class="project work">
<p>abcdef</p>
</div>
<div class="project work">
<p>abcdef</p>
</div>
<div class="project work">
<p>abcdef</p>
</div>
<div class="project research">
<p>abcdef</p>
</div>
Run Code Online (Sandbox Code Playgroud)
projects:first-child
工作正常,research:first-child
不坚持.有任何想法吗?
演示它不起作用,但最好的方法是什么?
你能为CSS3多列添加最小高度吗?
当文本只有四行而不是强制一行到第二列时,我宁愿只有一个列.
例如,我宁愿:
Lorem ipsum dolor sit amet
sodales id ipsum ipsum mauris
interdum qui congue
nisl quis, turpis tristique
Run Code Online (Sandbox Code Playgroud)
不是这个:
Lorem ipsum dolor sit amet nisl quis, turpis tristique
sodales id ipsum ipsum mauris
interdum qui congue
Run Code Online (Sandbox Code Playgroud)
有什么建议?
如何克隆元素并将其插入5次?这当然是基本陈述:
$('.col').clone().insertAfter('.col');
Run Code Online (Sandbox Code Playgroud)
这是我需要得到的:
<div class="col" id="original"> </div>
<div class="col"> </div>
<div class="col"> </div>
<div class="col"> </div>
<div class="col"> </div>
<div class="col"> </div>
Run Code Online (Sandbox Code Playgroud)
选择器不需要使用唯一的id,它也可以是类选择器.
我可以重复四次基本陈述,但必须有更优雅的方式吗?
这个div中的文本是否有选择器而不将其包装在<p>
标记中,或者可以使用jquery/javascript查找所有文本并将其包装在<p>
标记中?
<div class="content">
Some content in here.
<img src="image" alt="image" />
</div>
Run Code Online (Sandbox Code Playgroud)
我无法应用其他HTML标记,并希望以不同方式为文本设置样式.
我想要将文本包装<p>
成:
<div class="content">
<p>Some content in here.</p>
<img src="image" alt="image" />
</div>
Run Code Online (Sandbox Code Playgroud)
或者我可以用CSS选择仅仅没有HTML标记的文本来设置它吗?
我试图写出50%的身高作为补充:.scrollTop() + 50%}
而不是.scrollTop() + 200}
当鼠标离开时,#tail
div会回到窗口高度的一半.
.bind('mouseleave', function(){
$('#wrapper').unbind('mousemove');
$('#tail').animate({top:$('body').scrollTop() + 50%},300)
});
Run Code Online (Sandbox Code Playgroud)
什么是添加百分比值的正确方法?
谢谢
我正在使用以下内容查找其中的图像.content
并将其宽度应用于.project
父宽度.
$('.content').find('img').each(function () {
var $this = $(this), width = $this.width();
{
$(this).closest('.project').css("width", width);
}
});
Run Code Online (Sandbox Code Playgroud)
我的问题是它没有找到最大的图像.content
,有时会应用小于最大图像的宽度,并且会产生布局问题.
任何帮助都会很棒.谢谢.
编辑
Woops,细节错了,答案很棒!我只需要应用父project
div 的最大宽度.
建立Sudhir的答案.
如果有效,这不起作用?
$(document).ready(function() {
var max_width = 0;
$('.content').find('img').each(function(){
var this_width = $(this).width();
if (this_width > max_width) max_width = this_width;
});
$(this).closest('.project').css('width', max_width + 'px');
});
Run Code Online (Sandbox Code Playgroud)
布局示例.有很多项目.
<div class="container">
<div class="project">
<div class="content">
<img src="small.jpg" height="100" width="100" />
<img src="large.jpg" height="400" width="600" />
<img src="medium.jpg" height="400" width="600" …
Run Code Online (Sandbox Code Playgroud) 我试图找到一个外部元素的高度,.content
并将其应用于内部元素blockquote
减去100px
.
$("blockquote").height($(".content").height());
Run Code Online (Sandbox Code Playgroud)
这会产生600px的当前结果并将它们设置为相同的高度,但我不知道如何将数学应用于最终输出.600px - 100px.然后将此数学结果应用为.height
blockquote,现在应该是500px.
任何帮助都会很棒
我想改变一个div之后所有条目的样式.见例子.儿童选择器可以实现吗?谢谢!
<div class="wrapper">
<div class="entry">content</div>
<div class="entry">content</div>
<div class="CHANGE">content</div>
<div class="entry">content</div>
<div class="entry">content</div>
</div>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在努力实现这一目标:
<div class="content">
<img src= />
<img src= />
<div class="slideshow"> <img src= /><img src= /><img src= /></div>
Some text here
<a href="#">Link</a>
<i>Italic text</i>
etc more text.
</div>
<div class="content">
<img src= />
<img src= />
<div class="slideshow"> <img src= /><img src= /><img src= /></div>
<div class="description"
Some text here
<a href="#">Link</a>
<i>Italic text</i>
etc more text.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我尝试过文本节点,但它包含了描述div中的所有行文本.我正在尝试检测第一行文本,直到最后一行文本.如果有帮助,说明后将没有图像,视频或幻灯片.
我必须找不到find节点类型= 3的东西
任何建议都会很棒