我可以在HTML的“小类”中嵌套一个 吗?

问题描述 投票:0回答:1

我已经合并了很多HTML标记,以得到我想要的内容,并且效果很好。但是,我想知道它是否“正确”

更新:我认为这不是“正确”,请参见此链接:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small

因此,要稍微改变我的问题,我可以将我的“ p”标签更改为“ span”,对吗?那应该使它更正确。

我指的是“小类”中的嵌套段落标签

这里是代码:

<div class="card b-1 hover-shadow mb-20">
    <div class="media card-body">
        <div class="media-left pr-12">
            <img class="avatar avatar-xl no-radius" src="https://bootdey.com/img/Content/avatar/avatar1.png" alt="...">
        </div>
        <div class="media-body">
            <div class="mb-2">
                <span class="fs-20 pr-16"> XHossein Shams</span>
            </div>
            <small class="fs-16 fw-300 ls-1">


                <input type="checkbox" class="read-more-state" id="post-1" />

                <p class="read-more-wrap">Lorem ipsum dolor sit amet, consectetur adipisicing elit. <span class="read-more-target">Libero fuga facilis vel consectetur quos sapiente deleniti eveniet dolores tempore eos deserunt officia quis ab? Excepturi vero tempore minus beatae voluptatem!</span></p>

                <label for="post-1" class="read-more-trigger"></label>

            </small>
        </div>
        <div class="media-right text-right d-none d-md-block">
            <p class="fs-14 text-fade mb-12"><i class="fa fa-map-marker pr-1"></i> Menlo Park, CA</p>
            <span class="text-fade"><i class="fa fa-money pr-1"></i> $60 per hour</span>
        </div>
    </div>
    <footer class="card-footer flexbox align-items-center">
        <div>
            <strong>Cost of Tool:</strong>
            <span>Free &amp; Paid</span>
        </div>
        <div class="card-hover-show">
            <a class="btn btn-xs fs-10 btn-bold btn-info" href="#">Tool Home</a>
            <a class="btn btn-xs fs-10 btn-bold btn-primary" href="#" data-toggle="modal" data-target="#modal-contact">Contact</a>
        </div>
    </footer>
</div>

我是否认为这行是正确的:

<small class="fs-16 fw-300 ls-1">

^^^这基本上是一个“ div”-正确吗?

这里是CSS,如果有帮助的话:

.pr-12 {
    padding-right: 12px !important;
}

.mb-20 {
    margin-bottom: 20px !important;
}

.b-1 {
    border: 1px solid #ebebeb !important;
}

.card {
    border: 0;
    border-radius: 0;
    /* margin-bottom: 30px; */
    -webkit-transition: .5s;
    transition: .5s;
}

.card {
    position: relative;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-direction: column;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: .25rem;
}

.media {
    padding: 16px 12px;
    -webkit-transition: background-color .2s linear;
    transition: background-color .2s linear;
}

.media {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-align: start;
    align-items: flex-start;
}

.card-body {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    padding: 1.25rem;
}

.media .avatar {
    flex-shrink: 0;
}

.no-radius {
    border-radius: 0 !important;
}

.avatar-xl {
    width: 64px;
    height: 64px;
    line-height: 64px;
    font-size: 1.25rem;
}

.avatar {
    position: relative;
    display: inline-block;
    /* width: 36px;
    height: 36px; */
    width: 70px;
    height: 70px;
    line-height: 36px;
    text-align: center;
    border-radius: 100%;
    background-color: #f5f6f7;
    color: #8b95a5;
    text-transform: uppercase;
}

img {
    max-width: 100%;
}

img {
    vertical-align: middle;
    border-style: none;
}

.mb-2 {
    margin-bottom: .5rem!important;
}

.fs-20 {
    font-size: 20px !important;
}

.pr-16 {
    padding-right: 16px !important;
}

.ls-1 {
    letter-spacing: 1px !important;
}

.fw-300 {
    font-weight: 300 !important;
}

.fs-16 {
    font-size: 12px !important;
}

.media-body>* {
    margin-bottom: 0;
}

small, time, .small {
    font-family: Roboto,sans-serif;
    font-weight: 400;
    font-size: 11px;
    color: #8b95a5;
}

.fs-14 {
    font-size: 14px !important;
}

.mb-12 {
    margin-bottom: 12px !important;
}

.text-fade {
    color: rgba(77,82,89,0.7) !important;
}

.card-footer:last-child {
    border-radius: 0 0 calc(.25rem - 1px) calc(.25rem - 1px);
}

.card-footer {
    background-color: #fcfdfe;
    border-top: 1px solid rgba(77,82,89,0.07);
    color: #8b95a5;
    padding: 10px 20px;
}

.flexbox {
    display: -webkit-box;
    display: flex;
    -webkit-box-pack: justify;
    justify-content: space-between;
}

.align-items-center {
    -ms-flex-align: center!important;
    align-items: center!important;
}

.card-footer {
    padding: .75rem 1.25rem;
    background-color: rgba(0,0,0,.03);
    border-top: 1px solid rgba(0,0,0,.125);
}
/*

.card-footer {
    background-color: #fcfdfe;
    border-top: 1px solid rgba(77, 82, 89, 0.07);
    color: #8b95a5;
    padding: 10px 20px
} */

.card-footer>*:last-child {
    margin-bottom: 0
}

.hover-shadow {
    -webkit-box-shadow: 0 0 35px rgba(0, 0, 0, 0.11);
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.11)
}

.fs-10 {
    font-size: 10px !important;
}

谢谢!

html css
1个回答
0
投票

您确定吗? HTML非常灵活,您可以编写一整堆无效的标记,并且看上去已经摆脱了(目前)。这并不意味着您应该。

您应该编写有效的html,因为您可以更有力地保证它现在/将来都将始终如一地工作。您无法使用无效代码获得此类保证。您还应该编写语义有效的HTML,因为它可以更好地提示文档的结构和意图。

您不应该根据标签/元素提供的默认样式来选择标签/元素。最典型的示例是使用h3,而h2是要使用的正确标签,但需要较小的字体。使用正确的标签,然后适当设置样式。

就您而言,aside似乎很合适,但是如果不知道文档的完整上下文,就很难说出来。

aside
.pr-12 {
  padding-right: 12px !important;
}

.mb-20 {
  margin-bottom: 20px !important;
}

.b-1 {
  border: 1px solid #ebebeb !important;
}

.card {
  border: 0;
  border-radius: 0;
  /* margin-bottom: 30px; */
  -webkit-transition: .5s;
  transition: .5s;
}

.card {
  position: relative;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
  border: 1px solid rgba(0, 0, 0, .125);
  border-radius: .25rem;
}

.media {
  padding: 16px 12px;
  -webkit-transition: background-color .2s linear;
  transition: background-color .2s linear;
}

.media {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: start;
  align-items: flex-start;
}

.card-body {
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  padding: 1.25rem;
}

.media .avatar {
  flex-shrink: 0;
}

.no-radius {
  border-radius: 0 !important;
}

.avatar-xl {
  width: 64px;
  height: 64px;
  line-height: 64px;
  font-size: 1.25rem;
}

.avatar {
  position: relative;
  display: inline-block;
  /* width: 36px;
    height: 36px; */
  width: 70px;
  height: 70px;
  line-height: 36px;
  text-align: center;
  border-radius: 100%;
  background-color: #f5f6f7;
  color: #8b95a5;
  text-transform: uppercase;
}

img {
  max-width: 100%;
}

img {
  vertical-align: middle;
  border-style: none;
}

.mb-2 {
  margin-bottom: .5rem!important;
}

.fs-20 {
  font-size: 20px !important;
}

.pr-16 {
  padding-right: 16px !important;
}

.ls-1 {
  letter-spacing: 1px !important;
}

.fw-300 {
  font-weight: 300 !important;
}

.fs-16 {
  font-size: 12px !important;
}

.media-body>* {
  margin-bottom: 0;
}

small,
time,
aside,
.small {
  font-family: Roboto, sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: #8b95a5;
}

.fs-14 {
  font-size: 14px !important;
}

.mb-12 {
  margin-bottom: 12px !important;
}

.text-fade {
  color: rgba(77, 82, 89, 0.7) !important;
}

.card-footer:last-child {
  border-radius: 0 0 calc(.25rem - 1px) calc(.25rem - 1px);
}

.card-footer {
  background-color: #fcfdfe;
  border-top: 1px solid rgba(77, 82, 89, 0.07);
  color: #8b95a5;
  padding: 10px 20px;
}

.flexbox {
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: justify;
  justify-content: space-between;
}

.align-items-center {
  -ms-flex-align: center!important;
  align-items: center!important;
}

.card-footer {
  padding: .75rem 1.25rem;
  background-color: rgba(0, 0, 0, .03);
  border-top: 1px solid rgba(0, 0, 0, .125);
}


/*

.card-footer {
    background-color: #fcfdfe;
    border-top: 1px solid rgba(77, 82, 89, 0.07);
    color: #8b95a5;
    padding: 10px 20px
} */

.card-footer>*:last-child {
  margin-bottom: 0
}

.hover-shadow {
  -webkit-box-shadow: 0 0 35px rgba(0, 0, 0, 0.11);
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.11)
}

.fs-10 {
  font-size: 10px !important;
}
© www.soinside.com 2019 - 2024. All rights reserved.