在下面的代码中,我试图让h1元素具有最高利润率.当我将位置设置为在css中内联时,margin-top不会显示.但是,当我将其更改为内联块时,它确实如此.我想知道是否有人可以解释为什么会这样.谢谢.
编辑:这是jsfiddle中的代码:http://jsfiddle.net/pjPdE/
这是我的HTML:
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="MyFirstWebsite.css">
<title>
Max Pleaner's First Website
</title>
</head>
<body>
<h1>Welcome to my site.</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是CSS
body {
background-image:url('sharks.jpg');
}
h1 {
background-color:#1C0245;
display:inline;
padding: 6.5px 7.6px;
margin-left:100px;
margin-top:25px;
}
Run Code Online (Sandbox Code Playgroud) 所以我设置了一个这样的变量:
$variable-name: left;
Run Code Online (Sandbox Code Playgroud)
在我的CSS中,我有一个属性border-left的样式
如果我想将变量替换为属性的名称,我使用以下语法:
border-#{$variable-name}:
Run Code Online (Sandbox Code Playgroud)
我从来没有见过这个标签 - >大括号业务与变量替代.
这种语法是否具有更广泛的意义,或者它只是在这种情况下使用的东西?
非常感谢您花时间阅读我的问题,而那些回复帮助的人非常友好.
我在学习期间遇到了一些我不理解的语法.
puts "He is %d (%3.2f in floating point terms) pounds heavy." % [weight, weight]
Run Code Online (Sandbox Code Playgroud)
我不了解这一点的目的是3.2.谢谢参观!
PS顺便说一下weight变量最初是以磅为单位定义的.
我在codeschool.com上学习CSS课程,我对特定代码感到困惑.我应该编辑代码来测试CSS的特定功能,我得到了正确的答案,但我不明白为什么代码实际上有效.这是html:
<!doctype html>
<html lang="en">
<head>
<title>Sven's Snowshoe Emporium</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<section id="home" class="content home group">
<aside>
<p>Did you know that Sven's Snowshoe Emporium produces the highest quality snowshoes in North America? <a href="#">Find out more</a>.</p>
</aside>
<article>
<h3>New Fall Styles</h3>
<p>Be the first at your resort to sport the hot new tennis-themed snow kicks, now available in the <a href="#">store</a>.</p>
<a class="button" href="#">See all products</a>
</article>
</section>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS是
.home a {
color: #c09e79; …Run Code Online (Sandbox Code Playgroud) HTML片段:
<li class = "li_image"></li>
Run Code Online (Sandbox Code Playgroud)
CSS片段:
li_img {
width:28px;
height:32px;
background:url(https://ssl.gstatic.com/gb/images/v1_90902864.png) 10 15;
}
Run Code Online (Sandbox Code Playgroud)
知道为什么这不起作用吗?此列表项甚至没有出现在列表中.
我无法理解为什么word没有资本化或升级.
class Book
attr_accessor :title
def title=(changed_title)
changed_title.split(" ").map!{|word|
word.to_s.capitalize
}.join(" ")
@title = changed_title
end
end
book = Book.new
book.title = "check"
puts book.title
# >> check
Run Code Online (Sandbox Code Playgroud) 跑步score([1,1,1,1])应该导致1100,但我得到了1000,我不知道为什么.我希望rubyist可以看看它,让我知道出了什么问题.我有这个代码设置一个特定的方式,因为它必须通过除此之外的其他测试.这是代码:
def score(dice)
score = 0
done_nos = []
dice.each do |die|
unless done_nos.include?(die)
if dice.to_s.scan(/#{die}/).length >= 3
score +=
if die == 1
1000
else
(100 * die.to_i)
end
if die == (5 || 1)
score += ((dice.to_s.scan(/#{die}/).length - 3) *
if die == 5
50
else
100
end
)
end
elsif die == 1
score += (dice.to_s.scan(/#{die}/).length * 100)
elsif die == 5
score += (dice.to_s.scan(/#{die}/).length * 50)
end
done_nos << die …Run Code Online (Sandbox Code Playgroud) 嘿所以我试图让javascript/jquery将一些盒子div插入我的DOM - 无法弄清楚为什么它不起作用.小心协助我?在这里查看:http: //codepen.io/anon/pen/gobcd
编辑(代码):
$document.ready(
for(i=0; i<17; i++){
$("#square_holder").append("<div class='block'></div>");
};
button.onclick=function(){
console.log("Prior grid setup cleared. Next you will be prompted for a new amount.")
var newnumber = gets.chomp;
console.log("You entered: #{newnumber}. Watch in awe as the grid fills ..... ")
};
);
Run Code Online (Sandbox Code Playgroud)