html - 垂直对齐中间不起作用,超链接搞乱了格式?

标签 html css

我希望三个链接框中的文本在中间垂直对齐 - 但由于某些原因它们不会?

我还希望三个运动选项中的每一个都位于整个 div 中,成为一个可点击的框。我已将“马拉松”div 设为可点击,但它弄乱了对齐方式

这两个问题是什么?

*{
   margin: 0;
   padding: 0;
   }/*
   border: 0;
   outline: 0;
   font-size: 100%;
   vertical-align: baseline;
   background: transparent;
   }*/
html,
body {
   height:100%;
   width: 100%;
}
.parent-container {
   min-height:100%;
   width: 100%;
   position:relative;
   background: black;
   text-align: center;

   margin: 0 auto;

}
.child-container{
   margin: 0 auto;
   width: 80%;
   height: 60%;
   display:flex;
   justify-content: center;
   left: 10%;
   top: 20%;
   background: black;
   position: absolute;
   flex-direction: column;
   align-items: center;
   border-radius: 0%;
   border: 2px solid #39ff14 ;
   font-family: 'Montserrat';
}
.Marathon {
   top: 17.5%;
   height: 10%;
   width: 50%;
   border: 2px solid #39ff14 ;
   margin-top: auto;
}
.Marathon:hover{
   background: grey;
}
.Hockey:hover{
   background: grey;
}
.Cycling:hover{
   background: grey;
}
.Hockey {
   border: 2px solid #39ff14 ;
   width: 50%;
   height: 10%;
   top: 45%;margin-top: auto;
}
.Cycling {
   height: 10%;
   width: 50%;
   border: 2px solid #39ff14 ;
   top: 72.5%;
   margin-top:auto;
   margin-bottom:auto;
}
 h1{
   color:#39ff14;
   font-family: 'Nunito';
   padding-top: 5%;
   text-align: left;
   margin-left: 10%;
}
a{
   text-decoration: none;
}
.child-container a{
   color: #39ff14;
   text-decoration: none;
}
#container {
   min-height:100%;
   position:relative;
}
#header {
   background:#ff0;
   padding:10px;
}
#body {
   padding:10px;
   padding-bottom:60px;   /* Height of the footer */
}
#footer {
   position:absolute;
   bottom:0;
   width:100%;
   height:60px;   /* Height of the footer */
   background:#6cf;
}
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="refresh" content="5">
	<link type="text/css" rel="stylesheet" href="Styles.css" />
	<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" />
	<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
	<title>My Map App</title>
</head>
<body>

<div class="parent-container"> 
	<h1>My Map App</h1>
	<div class="child-container">
				<a href="marathon.php"><div class="Marathon">Marathon</div></a>
				<div class="Hockey"><a href="hockey.php">Hockey</a></div>
    			<div class="Cycling"><a href="cycling.php">Cycling</a></div>
    		
		</div>
	
</div>









</body>
</html>

另外,我希望我的网络应用程序能够很好地显示在我的手机上。目前,我的网络应用程序在我的 PC 上显示很好,但是当我在移动设备上打开时,标题“我的 map 应用程序”很小!我该如何解决这个问题?

提前致谢 PS,对此非常陌生!

最佳答案

您应该删除 Hockey、Cycling 和 Marathon 的所有这些单独样式。并将其添加到您的 .child-container风格:

flex-direction: column;
align-items: center;

虽然我不会推荐如此笼统的东西,但您的链接的更全局样式可能看起来像这样:

.child-container > * {
    padding: 12px 10%;
    border: solid 2px #39ff14;
    min-width: 150px;
    margin-bottom: 20px;
}

最后,将此添加到文档的头部,这样移动设备就不会缩小:
<meta name="viewport" content="width=device-width, initial-scale=1">

关于html - 垂直对齐中间不起作用,超链接搞乱了格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49820782/

相关文章:

javascript - 在 inIonic 中使用范围 slider 显示数字时出现问题

html - 用响应图像填充 div 背景

javascript - jquery simpleweather 无法识别

html - 是否可以在同一个 html 页面中多次使用相对位置?

html - 如何让div标签在页面中间居中

html - TABBED 内容没有出现在 CSS 中

css - 在 parent 中选择一定数量的 child 或 child 选择器。 CSS

javascript - 绘制 Canvas 不工作

html - CSS,图像周围的框不会消失

css - 如何获得不规则、可扩展的 CSS 多边形