gpt4 book ai didi

html - 表格内闪烁的插入符号

转载 作者:行者123 更新时间:2023-11-28 07:16:19 25 4
gpt4 key购买 nike

我想在 Twitter bootstrap 3 站点的表单内添加一个闪烁的插入符号/光标。有一个用于 html 和 css 的 codepen,但如果代码与 bootstrap 一起工作,我需要有关在哪里添加代码的帮助?我是新手,也很想学习,但我浏览了又浏览,没有任何结果。

代码笔在这里 http://codepen.io/ArtemGordinsky/pen/GnLBq

html
<span class="blinking-cursor">|</span>

css
.blinking-cursor {
font-weight: 100;
font-size: 30px;
color: #2E3D48;
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
}

@keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}

@-moz-keyframes blink {
from, to {
color: transparent;
}
50% {
color: black;
}
}

@-webkit-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}

@-ms-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}

@-o-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}

最佳答案

只需将输入和闪烁的图标包装到一个容器中,然后将闪烁的图标放在输入中。

/* The container */
.input-container {
position: relative;
}

/* Ensure the font-size is the same as the blinking icon */
.input-container input {
border: 1px solid gray;
font-size: 30px;
padding:0 5px;
}

/* Position it where you want. Must be position: absolute! */
.input-container .blinking-cursor {
position: absolute;
left: 5px; /* The same as padding on the input */
}

/* This will hide the blinking cursor when the user clicks on the input */
.input-container input:focus + .blinking-cursor{
visibility: hidden;
}

/* The code below is from the codepen: http://codepen.io/ArtemGordinsky/pen/GnLBq */
.blinking-cursor {
font-weight: 100;
font-size: 30px;
color: #2E3D48;
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
}
@keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
@-moz-keyframes blink {
from, to {
color: transparent;
}
50% {
color: black;
}
}
@-webkit-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
@-ms-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
@-o-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
<div class="input-container">
<input type="text">
<span class="blinking-cursor">|</span>
</div>

您可能想要进一步编辑样式,但这会让您朝着想要的方向前进。

关于html - 表格内闪烁的插入符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32330692/

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