gpt4 book ai didi

javascript - 需要显示篮球的前三个字母,然后是点

转载 作者:行者123 更新时间:2023-11-30 15:20:59 25 4
gpt4 key购买 nike

  • 我是 CSS 新手。
  • 我在 flex 属性方面遇到了很大的麻烦。
  • 当它的尺寸变大时它工作正常。
  • 但是当我将屏幕尺寸缩小到 320px 时,我遇到了问题...
  • 我需要显示篮球的前三个字母和点。
  • 所以它应该像 Bas...
  • 我尝试提供以下属性,但没有任何效果......
  • 你们能告诉我如何修复它吗……flex 有问题。
  • 在下面提供我的代码和 fiddle
@media only screen and (max-width: 320px) {

.sports-title {
border: 1px solid red !important;
-webkit-line-clamp: 1 !important;
-webkit-box-orient: vertical !important;
overflow: hidden !important;
display: -webkit-box !important;
padding-left: 0px !important;
width: 81px !important;
flex-grow: 0 !important;
flex-shrink: 0 !important;
flex-basis: 0px !important;
/* display: inline !important; */
/* flex: 0 !important; */
/* width: 77px !important; */
}

}

最佳答案

你可以使用white-space: nowrap代替flex,使用max-width代替width并添加 text-overflow: ellipsis

.sports {
background: #FFF;
border-bottom: 2px solid #FFF;
display: -webkit-flex;
display: flex;
overflow: hidden;
min-height: 73px;
pointer-events: auto;
position: fixed;
width: 100%;
top: 0;
padding: 24px 60px 21px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}

.sports-leftBlock {
background: transparent url(https://www.w3schools.com/css/paris.jpg) top left no-repeat !important;
/* border: 1px solid red; */
width: 55px;
height: 50px;
padding-left: 20px;
position: absolute;
left: 30px !important;
top: 25px !important;
}

.sports-leftBlock,
.sports-rightBlock {
position: absolute;
left: 0;
top: 0;
}

.sports-title {
-webkit-flex: 1;
flex: 1;
font-size: 18px;
font-weight: 500;
text-align: center;
display: block;
}

.sports-title {
font-family: 'Mercury Display', Times, serif;
font-size: 40px !important;
line-height: 1em;
vertical-align: baseline;
z-index: 1;
font-weight: 600 !important;
left: 108px;
bottom: 25px;
right: 136px;
color: #12395B !important;
}

.sports-title {
padding-left: 50px !important;
text-align: left !important;
}

.sports-rightBlock {
left: auto;
right: 0;
}

@media only screen and (max-width: 320px) {
.sports-title {
border: 1px solid red !important;
-webkit-line-clamp: 1 !important;
-webkit-box-orient: vertical !important;
overflow: hidden !important;
padding-left: 0px !important;
max-width: 100px !important;
text-overflow: ellipsis;
white-space: nowrap;
/* display: inline !important; */
/* flex: 0 !important; */
/* width: 77px !important; */
}
}

@media only screen and (max-width: 768px) {
.sports-leftBlock {
/* border: 1px solid black; */
width: 63px;
height: 50px;
}
}
<div class="sports">

<div class="sports-leftBlock">
</div>

<h1 class="sports-title">
basketball football swimming
</h1>

<div class="sports-rightBlock">
<button type="button" class="sports-close">
<span class="screenReader">Close Pop-up Dialog</span>
<span class="sports-closeIcon">
<span class="sports-closeIcon-icon"></span>
<span class="sports-closeIcon-highContrastGlyph" aria-hidden="true">×</span>
</span>
<span class="keyboardFocusRing"></span>
</button>
</div>

</div>

关于javascript - 需要显示篮球的前三个字母,然后是点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43727730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com