我必须创建一个样式来将背景颜色和填充应用于标题元素,从而产生以下预期外观(Photoshop模型):
http://f.cl.ly/items/1h09010w1t1I1B1q0r43/Screen%20Shot%202011-08-27%20at%2014.49.48.png
我的CSS如下(编辑显示相关规则)
h1 {
color: #fff;
line-height: 1.4;
background: #41a293;
padding: 2px 4px;
display:inline;
}
Run Code Online (Sandbox Code Playgroud)
这会产生以下结果:
http://f.cl.ly/items/3b3V0M0A0c262Z3m3k3D/Screen%20Shot%202011-08-27%20at%2014.52.24.png
我在元素的开头('S')和最后('e')得到填充,但不是文本中断的地方.由于它的父DIV的宽度而发生中断.这种情况经常发生并且是必要的.
有没有办法确保元素在文本中断的点处得到均匀填充?
非常感谢戴夫
编辑 - 我也应该说文本内容将通过CMS(Wordpress)显示.
我的页面包含许多OL列表,每个列表都显示一系列链接.单击每个链接时,内容向右滑出.点击每个链接时,内容然后重新滑入,然后再次滑出.
这是一个小提琴,展示了这一点:
http://jsfiddle.net/juxprose/xu3ck/15/
I would like to slow down the "back-in" part of the slide effect, so it matches the speed of the slide-out. You'll see currently it slides back-in very quickly - I'd like to adjust this speed.
Here's the JS part of the code, where the action happens:
$('.trg-open.website-title').click(function (e) {
e.stopPropagation();
$('.website-info').hide();
$(this).next('.website-info').show('slide', {direction: 'left'}, 1400);
});
Run Code Online (Sandbox Code Playgroud)
Any pointers gratefully appreciated, thanks.
我有一个CMS生成的HTML块.我想为一组特定的元素添加一些DIV包装器.
<ul id="gform_fields_1">
<li id="field_1_8" class="gfield">
<!-- content -->
</li>
<li id="field_1_9" class="gfield">
<!-- content -->
</li>
<li id="field_1_10" class="gfield">
<!-- content -->
</li>
<li id="field_1_11" class="gfield">
<!-- content -->
</li>
<li id="field_1_12" class="gfield">
<!-- content -->
</li>
<li id="field_1_13" class="gfield">
<!-- content -->
</li>
<li id="field_1_14" class="gfield">
<!-- content -->
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我想实现以下模式:
<ul id="gform_fields_1">
<div class="wrap">
<li id="field_1_8" class="gfield">
<!-- content -->
</li>
<li id="field_1_9" class="gfield">
<!-- content -->
</li>
<li id="field_1_10" class="gfield">
<!-- content -->
</li>
</div> …Run Code Online (Sandbox Code Playgroud) 可能重复:
最佳重定向方法?
你好
我正在使用一些遗留代码,其中包含用于用户注册/登录的模块.有一个块查询数据库以查看用户是否已登录,然后重定向到登录页面.
重定向由处理,<meta http-equiv='refresh' content='=2;index.php' />但我已经知道这是折旧的,并不适用于所有浏览器.
是否有另一种方法可以在下面的代码中重新定位?
$username = mysql_real_escape_string($_POST['username']);
$password = md5(mysql_real_escape_string($_POST['password']));
$checklogin = mysql_query("SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."'");
if(mysql_num_rows($checklogin) == 1)
{
$row = mysql_fetch_array($checklogin);
$email = $row['email'];
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$_SESSION['LoggedIn'] = 1;
echo "<h1>Success</h1>";
echo "<p>We are now redirecting you</p>";
echo "<meta http-equiv='refresh' content='=2;index.php' />";
}
else
{
echo "<h2>Error</h2>";
echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here …Run Code Online (Sandbox Code Playgroud) 是否可以使用jQuery来计算有多少字符,例如,a <li>,如果数量大于XX个字符,则将一个类应用于该元素?
我已经看到很多jQuery字符计数器(即http://plugins.jquery.com/plugin-tags/character-counter),我可以看到如何.addClass()处理这部分内容,但是在将它放在一起时遇到了一些麻烦.
任何指针都感激不尽.
非常感谢
感谢所有人的答案 - 找到一个对我有用的解决方案,如下所示
我想在用户提交表单时设置cookie.
我正在使用一些基于用户选中复选框设置cookie的遗留代码,但是这样可以在用户提交表单时简单地设置cookie.
这是我所拥有的,当选中复选框时,它有效:
$().ready(function()
{
$('.application-form').submit(function(e)
{
e.preventDefault();
if ($('.application-form input[name=marketing]').is(':checked'))
{
$.cookie('agreed_to_terms', '1', { path: '/', expires: 999999 });
}
});
});
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我不想在检查"营销"输入时设置cookie,而只是在表单提交时.像这样:
$().ready(function()
{
$('.application-form').submit(function(e)
{
e.preventDefault();
if ($('.application-form').submit();)
{
$.cookie('agreed_to_terms', '1', { path: '/', expires: 999999 });
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是,这并没有成功设置cookie,任何想法都会很棒,谢谢.
我应该首先说我不是一个PHP人,所以如果有人可以帮忙解决这个问题,我会尽力去理解任何建议.
我有以下代码访问API并通过PHP包装器输出一些数据:
$idMovie=11;
$pelinfo = $tmdb_V3->movieDetail($idMovie);
<h1><?php echo $pelinfo[original_title]; ?></h1>
<h2><?php echo $pelinfo[release_date]; ?></h2>
<img src="<?php echo $pelinfo[poster_path]; ?>">
<p><?php echo $pelinfo[overview]; ?></p>
Run Code Online (Sandbox Code Playgroud)
这很好,它显示了一个项目的数据.我需要做的是显示更多项目的数据.到目前为止,我只是重复了块并更改了$ idMovie变量 - 但这当然不是这样做的方法.
我想我需要这样做:
设置一个数组来保存每个变量,所以$ idMovie [12,34,56,78]
创建一个循环来遍历每个变量,并使用上面的代码块输出数据.
如果有人能指出我正确的方向,那将是最有帮助的.
谢谢戴夫
我期待实现以下目标:
这是我的图像标记:
<div id="maps">
<div class="map-box"><h2>London & South East</h2><a href="#"><img src="/img/map_london.jpg" /></a></div>
<div class="map-box"><h2>South West, Ireland and Wales</h2> <a href="#"><img src="/img/map_south_west.jpg" /></a> </div>
<div class="map-box"><h2>South Central & Home Counties</h2> <a href="#"><img src="/img/map_south_central.jpg" /></a> </div>
<div class="map-box"><h2>North England, Northern Ireland & Scotland</h2> <a href="#"><img src="/img/map_north.jpg" /></a> </div>
<div class="map-box"><h2>Midlands</h2> <a href="#"><img src="/img/map_midlands.jpg" /></a> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
当用户点击图像时,我想直接在其下方显示DIV的内容.像这样:
<div id="london">
<p>content london</p>
</div>
<div id="south-west">
<p>content south west</p>
</div>
<div id="south-central">
<p>content south central</p>
</div>
<div id="north">
<p>content north</p>
</div> …Run Code Online (Sandbox Code Playgroud)