由于div的固定宽度,我在一个div中有一个H1超过1行.我想仅将背景颜色设置为H1文本,以便背景仅保留在文本后面(例如,如果行的末尾有空白空间,则不应使用背景颜色).
另外,我需要设置左右填充文本.我试图将填充设置为标题但它也不起作用.
这是我想要得到的:

我试图通过设置inlineH1 的显示和设置背景颜色来实现这一点,但它似乎不起作用.以下是我的HTML和CSS以及演示.
HTML:
<div class="box">
<h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eget massa felis, at aliquam libero. </h1>
Run Code Online (Sandbox Code Playgroud)
CSS:
.box{
background: green;
overflow: hidden;
max-width: 100px;
margin: 50px auto;
padding: 20px;
}
h1{
background: yellow;
font-size: 30px;
float: left;
display: inline;
}
Run Code Online (Sandbox Code Playgroud)
如何以土耳其语显示日期?我正在尝试使用代码但它根本不打印任何内容.
setlocale(LC_ALL, 'tr_TR.UTF-8');
echo strftime("%e %B %Y %A", time());
Run Code Online (Sandbox Code Playgroud) 我有一个ul的底部边框.列表项中还有链接的底部边框.我想调整链接边框的位置,使其正好位于ul边框上,因此它看起来像这样:
我无法设置边框位置.这是我的代码:
HTML:
<ul>
<li><a href="#" class="active">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
ul{
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
margin-bottom: 5px;
padding-bottom: 5px;
border-bottom: 1px solid green;
}
ul li{
float: left;
margin-right: 10px;
}
ul li a{
text-decoration: none;
display: block;
}
ul li a.active{
border-bottom: 5px solid red;
}
Run Code Online (Sandbox Code Playgroud)
JSFiddle: http ://jsfiddle.net/sZ8Gu/
我正在尝试使用CSS,它适用于Firefox和Chrome,但在Safari(5.1)中无效.我检查过Safari支持n-child.我做错了什么?
CSS:
option:nth-child(2){
display: none;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<select>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我已将 Powerbuilder 9 应用程序迁移到 PowerBuilder 12.5。迁移后,部分功能无法使用。
以下代码来自具有 blob 参数 blobi 的函数。
long ll_position, ll_start, ll_end
ll_position=Pos(String(blobi),'~f@1~r~n',1) //does not work.
Run Code Online (Sandbox Code Playgroud)
上面的行在新版本中不起作用。我尝试检查从 ll_position 获得什么值:
messagebox("ll_position: ", ll_position)
In PB 9, it returns 1
In PB 12.5 it returns 0
Run Code Online (Sandbox Code Playgroud)
下一步:
ll_start=ll_position+5
ll_end=Pos(String(blobi),Char(126),ll_start) //does not work.
Run Code Online (Sandbox Code Playgroud)
我得到以下返回值:
messagebox("ll_end: ", ll_end)
In PB 9, it returns 10
In PB 12.5 it returns 0
Run Code Online (Sandbox Code Playgroud)
下一步:
dw_test.Object.numb[1]=Long(Mid(String(blobi),ll_start,ll_end -ll_start)) //does not work.
Run Code Online (Sandbox Code Playgroud)
我得到以下返回值:
long abc
abc = dw_test.Object.numb[1]
messagebox("dw value is: ", abc)
in PB 9 it …Run Code Online (Sandbox Code Playgroud) 我想在选择框中获取谷歌网络字体列表以选择字体.我正在尝试跟随功能,但它给出了错误.
码:
function get_google_fonts() {
$url = "https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha";
$result = json_response( $url );
$font_list = array();
foreach ( $result->items as $font ) {
$font_list[] .= $font->family;
}
return $font_list;
}
function json_response( $url ) {
$raw = file_get_contents( $url, 0, null, null );
$decoded = json_decode( $raw );
return $decoded;
}
Run Code Online (Sandbox Code Playgroud)
错误:
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP.
Run Code Online (Sandbox Code Playgroud)
如果我将https更改为http,我会收到此错误:
file_get_contents(http://www.googleapis.com/webfonts/v1/webfonts?sort=alpha): failed to open stream: HTTP request failed! …Run Code Online (Sandbox Code Playgroud) 我想用jQuery追加一个div,然后在附加div内的类上使用jQuery click函数.这是我的代码,如果我追加div它不起作用,但是如果div已经存在于html中它可以正常工作.
HTML:
<div class="add">
Add item
</div>
<div class="container">
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$('.add').click(function(e){
e.preventDefault();
var box = '<div class="box"><div class="remove">x</div></div>'
$('.container').append(box)
});
$('.remove').click(function(){
alert("remove");
});
Run Code Online (Sandbox Code Playgroud)
演示:
我想滑动一个div,在它完全滑落之后,我想<div>向下滑动另一个(默认是隐藏的).
我想下面的代码,但它确实我想要的,但我只是不明白的是,DIV滑下第一已向上滑动后完全,它看起来像格将立即开始出现在其他分区开始上述滑动效果.
那么我怎么能让它等到第一个div完全滑起然后它开始向下滑动.
HTML:
<div class="box">
<div class="up"></div>
<div class="down"></div>
</div>
<a href="#" id="hidediv">Hide me</a>
Run Code Online (Sandbox Code Playgroud)
CSS:
.up{
width: 100px;
height: 100px;
background: orange;
display: block;
}
.down{
width: 100px;
height: 100px;
background: red;
display: none;
}
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$("#hidediv").click(function () {
$(".up").slideUp(800);
$(".down").slideDown(800);
});
Run Code Online (Sandbox Code Playgroud)
演示:
我使用wordpress函数wp_remote_get从twitter获取json数据,如下所示:
$response = wp_remote_get('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter');
$json = json_decode($response['body']);
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是,如果twitter返回一些错误,它会在我的页面上完全产生问题.在这种情况下,我的页面上的内容不会在该错误部分后加载.那么,只有在没有错误的情况下,我怎样才能捕获错误并继续.
例如,如果推特限制超过,则返回以下响应:
{"request":"\/1\/statuses\/user_timeline.json?screen_name=twitter","error":"Rate limit exceeded. Clients may not make more than 150 requests per hour."}
Run Code Online (Sandbox Code Playgroud)
从上面的响应,我怎么能得到错误.我正在尝试关注,但它不起作用(我的页面根本没有加载)
if (!isset($json['error']){
//continue
}
Run Code Online (Sandbox Code Playgroud) 在下面的HTML,我想指定的宽度.left只有在有.right在div .wrapper,否则应采取全宽.例如,如果有.rightdiv,则宽度.left应为300px,否则应为500px.
我认为这可以使用css +选择器完成,但如果我不确定如何应用于.left.
<div class="wrapper">
<div class="left"></div>
<div class="right"></div>
</div>
.wrapper{
width: 500px;
}
.left{
width: 300px;
}
.right{
width: 200px;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 CSS 创建一个标签形状。使用以下代码,我可以使用左侧的箭头正确显示标签,如何将箭头移动到 div 的右侧而不是左侧?
HTML:
<div class="tags">
<a href="#">tag</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.tags a{
float:left;
height:24px;
line-height:24px;
position:relative;
font-size:11px;
margin-left:20px;
padding:0 10px 0 12px;
background:#0089e0;
color:#fff;
text-decoration:none;
}
.tags a:before{
content:"";
float:left;
position:absolute;
top:0;
left:-12px;
width:0;
height:0;
border-color:transparent #0089e0 transparent transparent;
border-style:solid;
border-width:12px 12px 12px 0;
}
Run Code Online (Sandbox Code Playgroud)
我有以下格式的字符串:
$date = "2012-07-22 17:48:24";
Run Code Online (Sandbox Code Playgroud)
我想在变量中获取年,月和日期并忽略时间.我正在努力追随:
list($year, $month, $day) = split('[-]', $date);
Run Code Online (Sandbox Code Playgroud)
这会将正确的值返回到$year和$month,但是$day获取:"22 17:48:24",而我只想获得22.
我正在使用基本标签功能.如果我尝试在除第一个选项卡之外的任何选项卡中添加任何其他代码,它似乎不起作用.例如,在下面的代码中,我试图使用插件来设置选择框的样式.如果选择框在第一个选项卡中,那么它可以工作,如果它在选择选项卡中,则它不会.这可能是因为一些jQuery加载sequance,但我在Firebug控制台中找不到任何错误.
请检查此演示以查看错误:
码:
$(document).ready(function () {
$('#tabs div').hide();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');
$('#tabs ul li a').click(function () {
$('#tabs ul li').removeClass('active');
$(this).parent().addClass('active');
var currentTab = $(this).attr('href');
$('#tabs div').hide();
$(currentTab).show();
return false;
});
$('select.style').customSelect();
});
Run Code Online (Sandbox Code Playgroud) html ×6
css ×5
php ×4
javascript ×3
jquery ×3
css3 ×2
api ×1
css-shapes ×1
date ×1
json ×1
localization ×1
powerbuilder ×1
string ×1
time ×1
twitter ×1
wordpress ×1