Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在<;p>;或<;部门>;_Html_Css - Fatal编程技术网

Html 在<;p>;或<;部门>;

Html 在<;p>;或<;部门>;,html,css,Html,Css,希望这是一个简单的问题 我有一个,上面有一些样式,使它看起来像英国的车牌 我想覆盖一个输入字段,以便用户可以键入注册表 即使将元素更改为绝对,我也很难获得叠加效果 HTML: <div> <p class="reg">007 ABC</p> <input id="vehicleReg" type="text" placeholder="Enter Vehicle Registration" /> </div> .reg

希望这是一个简单的问题

我有一个
,上面有一些样式,使它看起来像英国的车牌

我想覆盖一个输入字段,以便用户可以键入注册表

即使将元素更改为绝对,我也很难获得叠加效果

HTML:

<div>
   <p class="reg">007 ABC</p>
   <input id="vehicleReg" type="text" placeholder="Enter Vehicle Registration" />
</div>
.reg {
background-color: #ec0;
background: -webkit-linear-gradient(#ec0, #ca0);
border-radius: 6px;
box-shadow: 0 1px 3px rgba(0,0,0,.75);
font-family: number_plate;
display: inline-block;
/*padding: 0 50px 0 100px;*/
width: 220px;
position: relative;
font-size: 28px;
font-weight: bold;
line-height: 50px;
/*margin: 100px;*/
color: black;
/*    text-indent: 10px;*/
}

.reg::after {
background-color: rgba(255,255,255,.25);
color: #ec0;
content: "\25CC";
font-family: sans-serif;
font-size: 32px;
left: 0;
height: 50%;
line-height: 70px;
width: 100%;
padding-left: 14px;
position: absolute;
}

.vehicleReg { 
position: absolute;
right: 13%;
bottom: 17px;
width: 64%;
height: 31px;
background-color: transparent;
text-align:center;
}

谢谢

如果您绝对定位输入,那么在本例中,您需要使其相对于容器div

例如:

<div class="container">
  <p class="reg">007 ABC</p>
  <input id="vehicleReg" type="text" placeholder="Enter Vehicle Registration" />
</div>

.container { 
   position: relative;
}

007 ABC

.容器{ 位置:相对位置; }
见此:
你的意思是这样的吗


注册医生{
边界:无;
背景色:#ec0;
背景:-webkit线性梯度(#ec0,#ca0);
边界半径:6px;
盒影:0 1px 3px rgba(0,0,0,75);
字体系列:号码牌;
显示:内联块;
/*填充:0 50px 0 100px*/
宽度:220px;
位置:相对位置;
字号:28px;
字体大小:粗体;
线高:50px;
/*利润率:100像素*/
颜色:黑色;
/*文本缩进:10px*/
}
.reg::之后{
背景色:rgba(255255255.25);
颜色:#ec0;
内容:“\25CC”;
字体系列:无衬线;
字体大小:32px;
左:0;
身高:50%;
线高:70px;
宽度:100%;
左侧填充:14px;
位置:绝对位置;
}
#车辆如{
宽度:100%;
线高:45px;
字号:28px;
边界:无;
背景色:透明;
文本对齐:居中;
}
更改

.vehicleReg { 
 position: absolute;
 right: 13%;
 bottom: 17px;
 width: 64%;
 height: 31px;
 background-color: transparent;
 text-align:center;
}


VehiclerReg是输入字段的id,而不是类别。

有点慢,但以下内容将保留您的小欧洲图像,并将输入置于顶部渐变上方:

html

<div class="reg"><input id="vehicleReg" type="text" placeholder="Reg No" /></div>

稍有不相关,但如果您想让用户键入车牌号,请使用输入属性模式,并为其指定最大长度为8个字符

<input type="text" pattern="[A-Za-z0-9]{2}[0-9]{2}[ ][A-Za-z]{3}" maxlength="8" />

这强制了注册需要4个字母数字字符、一个空格和3个字符的模式


(HTML5的一部分只适用于最新的浏览器。即赶超速度较慢)

此外,您可以设置占位符文本的样式

placeholder {
font-family: number_plate;
font-weight: bold;
font-size: 28px;
text-transform:uppercase;
color:black;
text-align:center;   
}


您是否正在尝试将输入字段放在标牌的顶部?如果是这样的话,您的标记中不存在p?
.vehicleReg
元素中的文本会发生什么变化,只有
#vehicleReg
我认为您做得不对,只需在输入字段的按键上更改标记的文本。@Pete-是的,在注册牌的顶部。。p中的文本将消失。@Sasidharan-您的评论没有任何价值。对于一个有体面代表的人来说,我很惊讶你会回答这样的问题。作为将来的参考,在你轻视他人之前,你应该理解用户为什么同时使用了类和id。@OamPsy只想指出,这没有你的打火机上半部分,你不能点击上半部分input@Pete啊哈,连颜色都没注意到difference@OamPsy我同意皮特的看法,如果可以的话,请改为接受他的回答,因为我的造型只完成了一半,非常感谢。
.reg {
    background-color: #ec0;
    background: -webkit-linear-gradient(#ec0, #ca0);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.75);
    display: inline-block;
    /*padding: 0 50px 0 100px;*/
    width: 220px;
    position: relative;
    /*margin: 100px;*/
    color: black;
/*    text-indent: 10px;*/
    text-align:center
}

.reg::after {
    text-align:left;
    background-color: rgba(255,255,255,.25);
    color: #ec0;
    content: "\25CC";
    font-family: sans-serif;
    font-size: 32px;
    top:0;
    left: 0;
    height: 50%;
    line-height: 70px;
    width: 100%;
    padding-left: 14px;
    position: absolute;
}

#vehicleReg { 
   width: 70%;
    margin:auto;
   background-color: transparent;
    border:0;
    font-family: number_plate;
    font-weight: bold;
    line-height: 50px;
    font-size: 28px;
    text-transform:uppercase;
    position:relative; z-index:2;
}
<input type="text" pattern="[A-Za-z0-9]{2}[0-9]{2}[ ][A-Za-z]{3}" maxlength="8" />
placeholder {
font-family: number_plate;
font-weight: bold;
font-size: 28px;
text-transform:uppercase;
color:black;
text-align:center;