为了账号安全,请及时绑定邮箱和手机立即绑定

如何使文本区域从左上角移动

如何使文本区域从左上角移动

FFIVE 2023-10-17 15:12:24
我的文本区域位于左上角。我试图让它显示在显示屏的中央。这是我的 html/css:https://www.w3schools.com/code/tryit.asp?filename=GDAZWJBDC63Y
查看完整描述

3 回答

?
哆啦的时光机

TA贡献1779条经验 获得超6个赞

如果您希望它垂直居中,这应该可以解决问题。


.fill {    

    display: flex;

    align-items: center;

}

如果您也希望它水平居中,请justify-content像这样添加中心。


.fill {    

    display: flex;

    align-items: center;

    justify-content: center;

}


查看完整回答
反对 回复 2023-10-17
?
缥缈止盈

TA贡献2041条经验 获得超4个赞

所以我建议你研究一下 flex,它可以更轻松地对齐 DOM 中的项目。无论如何,除了回答你的问题之外,你可以将以下代码添加到你的 .fill 类中,它会将其水平和垂直居中。


.fill{

     display: flex;

     align-items: center; //To center it vertically

     justify-content: center; //To center it horizontal

    }


查看完整回答
反对 回复 2023-10-17
?
摇曳的蔷薇

TA贡献1793条经验 获得超6个赞

干得好:


.body {

  background-image: url(https://media.giphy.com/media/dQtH57ix3NWDKOQeQM/giphy.gif);

  width: 480px;

  height: 270px;

  float: left;

  border-radius: 20px;

}


.fill {

  background-color: #00000d;

  width: 480px;

  height: 270px;

  border-radius: 20px;

  opacity: .8;

  /* added these three fields */

  display: flex;

  align-items: center;

  justify-content: center;

}


.proxies {

  margin-left: auto;

  margin-right: auto;

}

<html>

<script src="https://kit.fontawesome.com/5276b58f35.js" crossorigin="anonymous"></script>


<body class="everything">

  <right class="body">

    <div class="fill">

      <textarea name="proxies" id="proxies" cols="30" rows="10"></textarea>

    </div>

  </right>

</body>


</html>


查看完整回答
反对 回复 2023-10-17
  • 3 回答
  • 0 关注
  • 55 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信