Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlay Input on <p> or <div>

Tags:

html

css

Hopefully an easy question.

I have a <p> which has some styling on it to make it look like a UK registration plate.

I want to overlay an input field so the user can type in a reg.

Here's my fiddle

I'm struggling to get the overlay even when changing elements to absolute.

HTML:

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

CSS:

.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;
}

Thanks

like image 738
Oam Psy Avatar asked Dec 01 '25 08:12

Oam Psy


1 Answers

A bit slow but the following will keep your little euro image and put the input above your top fade:

html

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

css

.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;
}

Example

like image 198
Pete Avatar answered Dec 02 '25 23:12

Pete



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!