下拉菜单被身体切断

时间:2017-06-03 13:15:44

标签: html css

我非常坚持这个。我有一个下拉菜单,当它溢出div时被切断。

在大多数情况下,我遇到过这是因为某些父元素有溢出:隐藏或未设置z-index,但我已经尝试过两者都没有效果......

这是代码:

@import url(https://fonts.googleapis.com/css?family=Catamaran);
body,
html {
  margin: 0;
  padding: 0;
  background-color: #aaf44d;
  overflow: visible;
}

html {
  font-family: "Catamaran", serif;
}

body {
  font-family: inherit;
  background-image: linear-gradient(216deg, #c8ff40, #a7eba2, #16ac2a);
}

textarea,
select,
button {
  font-family: inherit;
}

#submit {
  padding: 4px 10px;
  background-color: #1b9c34;
  border: 0 none;
  cursor: pointer;
  color: white;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  font-family: inherit;
  font-weight: bold;
}

#submit:hover {
  background-color: lightgray;
}

#submit:active {
  background-color: #1b9c34;
}

header {
  display: -ms-flexbox;
  display: -webkit-box;
  display: flex;
  background-color: #2f2f2f;
  border-bottom: 1px solid #37374a
}

h1 {
  color: white;
  height: 40px;
  line-height: 40px;
  vertical-align: middle;
  margin-left: 20px;
}

h2 {
  -webkit-background-clip: text;
  color: transparent;
  background-image: linear-gradient(216deg, #c8ff40, #a7eba2, #16ac2a);
  font-weight: 400;
  z-index: 3;
  text-align: center;
}

li {
  list-style: none;
}


/* Dropdown Button */

.dropbtn {
  background-color: #1b9c34;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  border-radius: 10%;
  cursor: pointer;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 50px 50px;
  padding-left: 40px;
  height: 80px;
  width: 100px;
}

.dropdown {
  position: relative;
  display: inline-block;
  margin-top: 80px;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #1b9c34;
  ;
  min-width: 140px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  z-index: 1;
}

.dropdown-content a:hover {
  background-color: lightgray;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: lightgray;
}

.uppertext {
  background-color: rgb(39, 39, 63);
  display: -ms-flexbox;
  display: -webkit-box;
  display: flex;
  -ms-flex-align: center;
  -webkit-box-align: center;
  align-items: center;
  -ms-flex-direction: column;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  flex-direction: column;
  height: 75vh;
  padding-bottom: 200px;
  clip-path: circle(120% at 50% -70vw);
  -webkit-clip-path: circle(120% at 50% -70vw);
  position: relative;
}

.bottom {
  position: relative;
  display: -ms-flexbox;
  display: -webkit-box;
  display: flex;
  -ms-flex-pack: center;
  -webkit-box-pack: center;
  justify-content: center;
  height: 62px;
  min-height: 42px;
  margin: 15px;
  background-color: red;
}
<header>
  <h1>Who is presenting?</h1>
</header>
<div class="uppertext">
  <h2>Submit a conference speaker or see who is presenting
  </h2>

  <form action="/quotes" method="POST">
    <input type="text" placeholder="name" name="name">
    <input type="text" placeholder="conference" name="conference">
    <input type="text" placeholder="location" name="location">
    <input type="text" placeholder="date" name="date">
    <button type="submit" id='submit'>Submit</button>
  </form>


  <div class="dropdown">
    <button class="dropbtn"></button>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </div>

</div>

1 个答案:

答案 0 :(得分:0)

我已经改变了一些css规则

@import url(https://fonts.googleapis.com/css?family=Catamaran);

body, html {
	margin: 0;
	padding: 0;
	background-color: #aaf44d;
	overflow: visible;
}

html {
	font-family: "Catamaran", serif;
}

body {
	font-family: inherit;
	background-image: linear-gradient(216deg, #c8ff40, #a7eba2, #16ac2a);
}

textarea, select, button {
	font-family: inherit;
}

#submit {
	padding: 4px 10px;
	background-color: #1b9c34;
	border: 0 none;
	cursor: pointer;
	color: white;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	font-family: inherit;
	font-weight: bold;
}

#submit:hover {
	background-color: lightgray;
}

#submit:active {
	background-color: #1b9c34;
}

body {
	background-color: #aaf44d;
	display: table;
	height: 100%;
	margin: 0;
	overflow: visible;
	padding: 0;
	position: relative;
	width: 100%;
}

header {
	display: -ms-flexbox;
	display: -webkit-box;
	display: flex;
	background-color: #2f2f2f;
	border-bottom: 1px solid #37374a;
	position: relative;
	z-index: 5;
}

h1 {
	color: white;
	height: 40px;
	line-height: 40px;
	vertical-align: middle;
	margin-left: 20px;
}

h2 {
	-webkit-background-clip: text;
	color: transparent;
	background-image: linear-gradient(216deg, #c8ff40, #a7eba2, #16ac2a);
	font-weight: 400;
	z-index: 3;
	text-align: center;
}

li {
	list-style: none;
}

/* Dropdown Button */
.dropbtn {
	background-color: #1b9c34;
	color: white;
	padding: 16px;
	font-size: 16px;
	border: none;
	border-radius: 10%;
	cursor: pointer;
	background-position: center;
	background-repeat: no-repeat;
	background-size: 50px 50px;
	padding-left: 40px;
	height: 80px;
	width: 100px;
}

.dropdown {
	position: relative;
	display: inline-block;
	margin-top: 80px;
}

.dropdown-content {
	display: none;
	position: absolute;
	background-color: #1b9c34;;
	min-width: 140px;
	box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
	z-index: 1;
}

.dropdown-content a {
	color: black;
	padding: 12px 16px;
	text-decoration: none;
	display: block;
	z-index: 1;
}

.dropdown-content a:hover {
	background-color: lightgray;
}

.dropdown:hover .dropdown-content {
	display: block;
}

.dropdown:hover .dropbtn {
	background-color: lightgray;
}

.uppertext {
	/*background-color: rgb(39,39,63);*/
	display: -ms-flexbox;
	display: -webkit-box;
	display: flex;
	-ms-flex-align: center;
	-webkit-box-align: center;
	align-items: center;
	-ms-flex-direction: column;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	flex-direction: column;
	height: calc(100vh);
	/*padding-bottom: 200px;
	clip-path: circle(120% at 50% -70vw);
  -webkit-clip-path: circle(120% at 50% -70vw);
  -moz-clip-path: circle(120% at 50% -70vw);*/
	position: relative;
}

.uppertext:before {
	background: rgb(39, 39, 63) none repeat scroll 0 0;
	border-radius: 50%;
	bottom: 0;
	content: "";
	height: 105%;
	left: 0;
	position: absolute;
	right: 0;
	top: -50%;
	width: 100%;
	z-index: 0;
}

.bottom {
	position: relative;
	display: -ms-flexbox;
	display: -webkit-box;
	display: flex;
	-ms-flex-pack: center;
	-webkit-box-pack: center;
	justify-content: center;
	height: 62px;
	min-height: 42px;
	margin: 15px;
	background-color: red;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Who is presenting?</title>
  <link rel="stylesheet" href="public/styles.css">

</head>

<body>

<header>
<h1>Who is presenting?</h1>
</header>
<div class = "uppertext">
<h2>Submit a conference speaker or see who is presenting<h2>



  <form action="/quotes" method="POST">
  <input type="text" placeholder="name" name="name">
  <input type="text" placeholder="conference" name="conference">
  <input type="text" placeholder="location" name="location">
  <input type="text" placeholder="date" name="date">
  <button type="submit" id = 'submit'>Submit</button>
  </form>


<div class="dropdown">
  <button class="dropbtn"></button>
  <div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link 3</a>
  </div>
</div>

</div>

</body>
</html>