diff --git a/homework1/.vscode/settings.json b/homework1/.vscode/settings.json new file mode 100644 index 0000000..5bf3a53 --- /dev/null +++ b/homework1/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "liveServer.settings.port": 5543, + "cSpell.words": [ + "dropbtn", + "navobj" + ] +} diff --git a/homework1/index.css b/homework1/index.css new file mode 100644 index 0000000..3d2ec8d --- /dev/null +++ b/homework1/index.css @@ -0,0 +1,85 @@ +/* 这是被index.html引用的css样式表 */ + +/* 设置全局样式:将所有元素的内边距和外边距初始化为 0 */ +* { + padding: 0; + margin: 0; +} + +/* 设置导航栏样式 */ +#navbar { + background-color: rgb(49, 42, 42); + width: 100%; + height: 50px; + /* 确保导航栏内对象居中 */ + display: flex; + align-items: center; +} + +/* 设置导航栏对象样式*/ +.navobj { + color: rgb(255, 255, 255); + margin-left: 10px; + margin-right: 10px; + display: inline-block; +} + +/* 确保导航栏内的链接无蓝字和下划线 */ +.navobj a { + color: inherit; + text-decoration: none; +} + +/* 下拉菜单容器样式 */ +.dropdown { + position: relative; + display: inline-block; +} + +/* 下拉菜单按钮样式 */ +.dropbtn { + color: white; + padding: 16px; + font-size: 16px; + border: none; + cursor: pointer; + display: flex; + align-items: center; +} + +/* 为下拉菜单按钮添加三角箭头 */ +.dropbtn::after { + content: ""; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-top: 5px solid white; + margin-left: 5px; +} + +/* 下拉菜单内容样式 */ +.dropdown-content { + display: none; + position: absolute; + background-color: rgb(49, 42, 42); + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); + z-index: 1; +} + +/* 下拉菜单内容链接样式 */ +.dropdown-content a { + color: rgb(255, 255, 255); + padding: 12px 16px; + text-decoration: none; + display: block; +} + +/* 鼠标悬停时下拉菜单内容链接样式 */ +.dropdown-content a:hover { + background-color: #8187db; +} + +/* 鼠标悬停时显示下拉菜单内容 */ +.dropdown:hover .dropdown-content { + display: block; +} diff --git a/homework1/index.html b/homework1/index.html new file mode 100644 index 0000000..43f2ace --- /dev/null +++ b/homework1/index.html @@ -0,0 +1,33 @@ + + +
+ + + +