您好我一直在垃圾邮件谷歌浏览器中的开发工具尝试添加边距到我的导航栏。预期的想法是使边距允许我在框之间创建间隙。任何帮助表示赞赏!
http://jsfiddle.net/3jp1d0fe/8/
CSS
div.container {
display: table;
display: table-row;
}
div.column {
display: table-cell;
vertical-align:middle;
text-align:center;
background-color:#c2ad80;
}
div.column a {
color:white;
font-family: Arial;
font-size: 12px;
text-decoration:none;
display:block;
height:100px;
width:100px;
display: table-cell;
vertical-align: middle;
}
div.column.current, div.column:hover {
background-color: #a2884f;
}
HTML
<div class="container">
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Solution%20Assessment.aspx"> Solution Assessment</a></div>
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Design.aspx"> Design</a></div>
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Build.aspx"> Build</a></div>
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Deploy.aspx"> Deploy</a></div>
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Test.aspx"> Test</a></div>
<div class="column"><a href="/sites/SharePointSDLC/SitePages/Live.aspx"> Live (BAU)</a></div>
</div>
JS
$(function () {
url = location.pathname.substr(1);
$('a[href*="' + url + '"]').closest(".column").addClass("current");
});
$(".column a").click(function () {
$(".current").removeClass("current");
$(this).closest(".column").addClass("current");
return false;
});
答案 0 :(得分:1)
margin
适用于除
标题,表和内联表之外的表格显示类型的元素之外的所有元素。它也适用于:: first-letter。
您可以使用
border-spacing
代替`margin``div.container { display: table; display: table-row; /* Added */ border-collapse:separate; border-spacing:5px; } div.column { display: table-cell; vertical-align:middle; text-align:center; background-color:#c2ad80; /* Added */ border:2px solid white; }
<强>段强>
$(function () { url = location.pathname.substr(1); $('a[href*="' + url + '"]').closest(".column").addClass("current"); }); $(".column a").click(function () { $(".current").removeClass("current"); $(this).closest(".column").addClass("current"); return false; });
div.container { display: table; display: table-row; border-collapse:separate; border-spacing:5px; } div.column { display: table-cell; vertical-align:middle; text-align:center; background-color:#c2ad80; /* Added */ border: 2px solid white; } div.column a { color:white; font-family: Arial; font-size: 12px; text-decoration:none; display:block; height:100px; width:100px; display: table-cell; vertical-align: middle; } div.column.current, div.column:hover { background-color: #a2884f; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <body> <div class="container"> <div class="column"><a href="https://www.google.co.uk"> Solution Assessment</a> </div> <div class="column"><a href="https://www.google.co.uk"> Design</a> </div> <div class="column"><a href="https://www.google.co.uk"> Build</a> </div> <div class="column"><a href="https://www.google.co.uk"> Deploy</a> </div> <div class="column"><a href="https://www.google.co.uk"> Test</a> </div> <div class="column"><a href="https://www.google.co.uk"> Live (BAU)</a> </div> </div> </body>
答案 1 :(得分:1)
试试这可能对你有帮助..
$(function () { url = location.pathname.substr(1); $('a[href*="' + url + '"]').closest(".column").addClass("current"); }); $(".column a").click(function () { $(".current").removeClass("current"); $(this).closest(".column").addClass("current"); return false; });
div.container { display: table; border-collapse: separate; border-spacing: 10px; } div.column { display: table-cell; border-spacing: 10px; vertical-align:middle; text-align:center; background-color:#c2ad80; } div.row { display:table-row; } div.column a { color:white; font-family: Arial; font-size: 12px; text-decoration:none; display:block; height:100px; width:100px; display: table-cell; vertical-align: middle; } div.column.current, div.column:hover { background-color: #a2884f; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body> <div class="container"> <div class="row"> <div class="column"><a href="https://www.google.co.uk"> Solution Assessment</a> </div> <div class="column"><a href="https://www.google.co.uk"> Design</a> </div> <div class="column"><a href="https://www.google.co.uk"> Build</a> </div> <div class="column"><a href="https://www.google.co.uk"> Deploy</a> </div> <div class="column"><a href="https://www.google.co.uk"> Test</a> </div> <div class="column"><a href="https://www.google.co.uk"> Live (BAU)</a></div> </div> </div> </body>
答案 2 :(得分:1)
就是这样,我更改为使用
background-color
代替a
代替.column
,然后将padding
添加到.column
,然后将悬停效果添加到.column a
.column
代替div.container { display: table; display: table-row; } div.column { display: table-cell; vertical-align:middle; text-align:center; padding: 2px; } div.column a { color:white; font-family: Arial; font-size: 12px; text-decoration:none; display:block; height:100px; width:100px; display: table-cell; background-color:#c2ad80; vertical-align: middle; } div.column.current a, div.column a:hover { background-color: #a2884f; }
arrayType
相关问题最新问题
- 我写了这段代码,但我无法理解我的错误
- 我无法从一个代码实例的列表中删除 None 值,但我可以在另一个实例中。为什么它适用于一个细分市场而不适用于另一个细分市场?
- 是否有可能使 loadstring 不可能等于打印?卢阿
- java中的random.expovariate()
- Appscript 通过会议在 Google 日历中发送电子邮件和创建活动
- 为什么我的 Onclick 箭头功能在 React 中不起作用?
- 在此代码中是否有使用“this”的替代方法?
- 在 SQL Server 和 PostgreSQL 上查询,我如何从第一个表获得第二个表的可视化
- 每千个数字得到
- 更新了城市边界 KML 文件的来源?