- This topic is empty.
-
AuthorPosts
-
July 24, 2019 at 8:24 am #293348
DmitryAi
ParticipantHi!
I have a next HTML-code:
SOME TEXT
and CSS-code for this:
.smi { height: 19.4%; }
.border { float: left; height: 100%; }
.bmid { width: 0;
overflow: hidden;
display: inline-block;
background: url(‘/img/mid.png’) no-repeat center;
background-size: 100% 100%; }
.bmid_anim { animation-name: smMiddleOn;
animation-timing-function: ease;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-fill-mode: forwards; }
@keyframes smMiddleOn { 100% { width: auto; } }And of course it doesn’t work because “width: auto; ”
But I have a several “smi” divs with different texts.
How I can make dynamic middle div?July 24, 2019 at 11:25 am #293350Paulie_D
MemberA Codepen.io demo would be useful here.
July 25, 2019 at 5:53 am #293381July 25, 2019 at 7:07 am #293385Paulie_D
MemberUse
max-widthinstead as you cannot animateautowidthJuly 25, 2019 at 7:46 am #293386DmitryAi
ParticipantThanks a lot!
Using max-width instead width solved the problem.
Amazing :)
August 12, 2019 at 2:44 am #294200DmitryAi
ParticipantHi!
I’ve got another problem.
What’s goes wrong when I’m add a paddings left and right side?
:(https://codepen.io/dmitry-ainutdinov/pen/bXeZbN
UPD:
Ok. Now I knew that max-width doesn’t take padding left and right.
But how it possible to fix?August 12, 2019 at 8:26 am #294210DmitryAi
ParticipantOk.
I’m add a wrap with “width: fit-content;”
It’s work.Don’t know is it best way?
August 12, 2019 at 4:05 pm #294254uxfed
Participantfit-content isn’t supported in IE or Edge. If you need to transition to an automatic width, a JS solution may be best.
October 10, 2019 at 10:13 am #297155DmitryAi
ParticipantI trying to make it in other way with
<
table> tag.
But immediately I’ve got a first problem:
why text in the table cell with paddings get a new line?
https://codepen.io/dmitry-ainutdinov/pen/rNNOwNp -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.