【问题标题】:I can't press buttons, select box when I center them (text-align: center;)我无法按下按钮,当我将它们居中时选择框(文本对齐:居中;)
【发布时间】:2019-03-20 17:21:30
【问题描述】:

我有一个 div 类,包含按钮、选择框和输入文本(在我的所有 jsp 文件中作为 div 共享),我在其中设置了 css 样式(文本对齐:居中);

当这个 div 向左对齐时,我可以按下并输入所有这些。

这是我包含的jsp文件http://scratchpad.io/first-protest-1771

如果我不包含整个代码,无论我如何对它们进行文本对齐,我的 div 都能正常工作。

谁能告诉我,怎么了?

【问题讨论】:

  • 在链接中,我只有 HTML 和 CSS,所有的 HTML 都包含在我的 jsp 文件中。
  • 对于像您这样的问题,需要在问题本身中发布minimal reproducible example,而不是指向第三方网站的链接。

标签: html css


【解决方案1】:

您可以使用此代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="javascript/lib/jquery-1.11.0.js"></script>
    <title>eBanking</title>
    <link rel="stylesheet" href="style.css">
        <style type="text/css">
        @media print {
            .example-screen {
                display: none;
            }
            .example-print {
                display: block;
            }
        }
        .extraCont {
            color: white;
        }
        td {
            /*   text-align: center; */
        }
        footer {
            position: fixed;
            left: 0;
            bottom: 0;
            width: 100%;
            background-color: red;
            color: white;
            text-align: center;
        }
        body {
            margin: 0;
            padding: 0;
            background: url(bg.jpg) no-repeat;
            background-size: cover;
            font-family: Arial;
        }
        .loginBox {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 350px;
            height: 420px;
            padding: 80px 40px;
            box-sizing: border-box;
            background: rgba(0, 0, 0, .5);
        }
        h2 {
            margin: 0;
            padding: 0 0 20px;
            color: #efed40;
            text-align: center;
        }
        h3 {
            color: #efed40;
        }
        h1 {
            color: #efed40;
            text-align: center;
        }
        .loginBox p {
            margin: 0;
            padding: 0;
            font-weight: bold;
            color: #fff;
        }
        .loginBox input {
            width: 100%;
            margin-bottom: 20px;
        }
        .loginBox input[type="text"],
        .loginBox input[type="password"] {
            border: none;
            border-bottom: 1px solid #fff;
            background: transparent;
            outline: none;
            height: 40px;
            color: #fff;
            font-size: 16px;
        }
        ::placeholder {
            color: rgba(255, 255, 255, .5);
        }
        .loginBox input[type="submit"] {
            border: none;
            outline: none;
            height: 40px;
            color: #fff;
            font-size: 16px;
            background: #ff267e;
            cursor: pointer;
            border-radius: 20px;
        }
        .loginBox input[type="submit"]:hover {
            background: #efed40;
            color: #262626;
        }
        .loginBox a {
            color: #fff;
            font-size: 14px;
            font-weight: bold;
            text-decoration: none;
        }
        .menuBox ul {
            margin: 0 auto;
            padding: 0px;
            list-style: none;
            text-align: center;
        }
        .menuBox ul li {
            float: left;
            width: 210px;
            height: 40px;
            background-color: black;
            color: white;
            opacity: .8;
            line-height: 40px;
            text-align: center;
            font-size: 20px;
            margin-right: 25px;
        }
        .menuBox ul li a {
            text-decoration: none;
            color: white;
            display: block;
            padding: 0px 15px;
        }
        .menuBox ul li a:hover {
            background-color: green;
        }
        .menuBox .menuboxli {
            text-align: center;
            margin: 0 auto;
            display: inline-block;
            vertical-align: middle;
            float: none;
        }
                ul li ul li {
            display: none;
        }
        ul li:hover ul li {
            display: block;
        }
        .sanBox {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 600px;
            height: 500px;
            padding: 80px 40px;
            box-sizing: border-box;
            background: rgba(0, 0, 0, .5);
        }
        .menuBox {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 870px;
            height: 500px;
            padding: 80px 40px;
            /*  box-sizing: border-box; */
            /*  background: rgba(0,0,0,.5)  ; */
        }
        .mapBox {
            position: absolute;
            top: 60%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 1280px;
            height: 600px;
            padding: 80px 40px;
            box-sizing: border-box;
            background: rgba(0, 0, 0, .5);
        }
        .user {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            overflow: hidden;
            position: absolute;
            top: calc(-100px/2);
            left: calc(50% - 50px);
        }
        .menuRight ul {
            list-style-type: none;
            margin: 0;
            padding: 10px;
            overflow: hidden;
        }
        .menuRight li {
            float: right;
        }
        .menuRight li a {
            display: inline-block;
            color: white;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
        }
        .vizCont {
            margin-top: 120px;
            text-align: center;
        }
        .white {
            color: white;
        }
        #renunta {}
        #renunta a {
            color: #fff;
            font-size: 14px;
            font-weight: bold;
            text-decoration: none;
        }    
    </style>
</head>
<body>
    <div class="menuRight">
        <ul>
            <li><a href="logout.jsp">Logout</a></li>
        </ul>
    </div>
    <div class="menuBox">
        <h1>eBanking</h1>
        <ul>
            <li class="menuboxli"><a>CONTURIffgfdfg</a>
                <ul>
                    <li><a href="administrareCont.jsp">AdministrareCont</a></li>
                    <li><a href="vizualizareCont.jsp">VizualizareCont</a></li>
                </ul>
            </li>
            <li class="menuboxli"><a>OPERATII</a>
                <ul>
                    <li><a href="transfer.jsp">Transfer</a></li>
                    <li><a href="alimentareCont.jsp">OperatiiInCurs</a></li>
                </ul>
            </li>
            <li class="menuboxli"><a>RAPOARTE</a>
                <ul>
                    <li><a href="extraCont.jsp">ExtraCONT</a></li>
                </ul>
            </li>
            <li class="menuboxli"><a href="aprobare.jsp">APROBARE</a></li>
        </ul>
    </div>
    <footer> Tomuta Dan Claudiu dannyetlv @2019 </footer>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2016-05-11
    • 2018-08-11
    • 2017-06-03
    • 2017-03-17
    • 2016-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    相关资源
    最近更新 更多