我一直在尝试使用MaterialiseCSS标签更改标签内容的背景颜色 - http://materializecss.com/tabs.html
如果您查看网站 - 您可以看到默认选项卡是白色但是'Test 1,Test2等'的背景颜色内容与网站其他部分的颜色相同。我想复制这个,但一直无法复制。每次我尝试更改CSS时,我都会以某种方式搞乱标签本身的外观。我希望有人可以帮我正确设置CSS。以下是代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<!-- Tabs -->
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a class="active" href="#test1">Tab 1</a></li>
<li class="tab col s3"><a href="#test2">Tab 2</a></li>
<li class="tab col s3"><a href="#test3">Tab 3</a></li>
<li class="tab col s3"><a href="#test4">Tab 4</a></li>
<li class="tab col s3"><a href="#test5">Tab 5</a></li>
</ul>
</div>
<div id="test1" class="col s12">Test 1</div>
<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 2</div>
<div id="test5" class="col s12">Test 3</div>
</div>
<!-- Init Tabs -->
<script type="text/javascript">
$(document).ready(function(){
$('ul.tabs').tabs();
});
</script>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/js/materialize.min.js"></script>
</body>
</html>
我一直在尝试编辑所有类,例如'test1'ID。但这也会与标签的底部发生冲突。
提前致谢。
答案 0 :(得分:0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<style>
li:nth-child(n+1){background-color:#ccc;}
#test1, #test2, #test3, #test4, #test5{background-color:pink;}
</style>
<body>
<!-- Tabs -->
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s2"><a class="active" href="#test1">Tab 1</a></li>
<li class="tab col s2"><a href="#test2">Tab 2</a></li>
<li class="tab col s2"><a href="#test3">Tab 3</a></li>
<li class="tab col s2"><a href="#test4">Tab 4</a></li>
<li class="tab col s2"><a href="#test5">Tab 5</a></li>
</ul>
</div>
<div id="test1" class="col s12">Test 1</div>
<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>
<div id="test5" class="col s12">Test 5</div>
</div>
<!-- Init Tabs -->
<script type="text/javascript">
$(document).ready(function(){
$('ul.tabs').tabs();
});
</script>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/js/materialize.min.js"></script>
</body>
</html>
&#13;
你的意思是这样的吗?首先,col值应该高达12,你给出的有3 * 5 = 15。