zoukankan      html  css  js  c++  java
  • css 边框上如何写入文字?

    方法一:

    1、首先,打开html编辑器,新建html文件,例如:index.html。

    2、在index.html中的<body>标签中,输入html代码:。

    <div style="margin-top: 30px; 200px;height:80px;border: 1px solid blue;">

    <div style="position: absolute;left: 30px;top: 15px;">文字</div>

    </div>

    3、浏览器运行index.html页面,此时实现了边框角落开口显示文字。

    方法二:

    这个可以通过相对定位使某元素恰好处在div的边框上的方式来实现

    1
    position:relative;

    下面举例说明

    1. 创建Html元素

      1
      2
      3
      4
      <div>
          <span class="title">我是边框上的文字</span>
          <span>我是边框内的文字</span>
      </div>
    2. 设置css样式

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      div{
          width:200px;
          height:100px;
          padding:5px 30px;
          margin:50px;
          border:4px solid #ebcbbe;
      }
      span.title{
          display:block;
          width:150px;
          height:30px;
          position:relative;
          top:-15px;
          text-aligncenter;
          backgroundwhite;
      }
    3. 观察显示效果

    方法三:

    <fieldset>
    <legend>文字内容</legend>
    <p>kkkk</p>
    </fieldset>
    这样就行

  • 相关阅读:
    python爬虫headers设置后无效解决方案
    idea建立web项目servlet映射的地址/jsp访问不到
    bootstrap栅格系统错位问题
    python2 python3共存解决方案
    Springboot+Thymeleaf框架的button错误
    星空雅梦
    星空雅梦
    星空雅梦
    星空雅梦
    星空雅梦
  • 原文地址:https://www.cnblogs.com/Antwan-Dmy/p/11798950.html
Copyright © 2011-2022 走看看