我的问题是:我无法data-id通过jQuery 设置增量到HTML元素.我能够提醒相同,但我没有设置HTML.如果我检查,元素没有变化.
jQuery的
$(document).ready(function() {
$("#search").click(function(){
var num = $(this).data('id');
num++;
$("span").text(num);
$(this).data('id', num);
});
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个
$(this).data('id') === num;
Run Code Online (Sandbox Code Playgroud)
这是一个jsFiddle演示
我v1.9.1在控制台中使用并且没有错误.如果有人能找到这个问题,它会很棒.
我做了一个英雄部分,内容与边框重叠.这是它的样子:
我想删除该灰色区域以使其透明并使背景可见.但正如你可以看到它在边界重叠.所以我不希望看到边界成为罢工.内容和图像是动态的,因此宽度可能会改变.
现场演示:在Codepen上
HTML
<div class="wrap">
<div class="border">
<h1 class="hero-title">We make your website beautiyul & usable </h1>
<span class="attr">— Citation, ABC Inc</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
@import url(https://fonts.googleapis.com/css?family=Playfair+Display:400,700,900);
body {
background: url('https://source.unsplash.com/category/nature') no-repeat center center #333;
color:#FFF;
font-family: "Playfair Display", Georgia, serif;
background-size:cover;
}
.wrap {
max-width:1200px;
margin:0 auto;
padding:130px 20px;
}
.border {
border:solid 10px #FFF;
text-align:center;
}
.attr {
position:relative;
top:-45px;
font-size:20px;
display:block;
}
.hero-title {
font-weight:700;
font-size:90px;
text-align:center;
margin:0 50px;
padding:0;
position:relative;
top:-75px;
background:#8b8b8b;
display:inline-block;
}
Run Code Online (Sandbox Code Playgroud)
现场演示: …
我想在图像上放一个小文字标签.有人可以帮我解决这个问题吗?
将图像放在div的背景中并在其上书写是一个选项但是当我正在处理动态项目时,我需要保持css静态
这是我尝试过的:
HTML:
<div class="image">
<p class="text">Category</p>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.image{
height:40%;
width:100%;
text-align:center;
padding-top:2px;
background-image:url(Lighthouse.jpg);
background-size:100% auto;
}
Run Code Online (Sandbox Code Playgroud)
使用这个我创建了这样的东西: 
现在,因为我将使用Django,我不希望图像在css中.我想把它放在我的html文件中.