HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="wrapper">
<div class="btn">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
<div class="form">
<label id="search">Enter Your Email address</label><br>
<input type="text" class="input">
</div>
</div>
* {
margin: 0;
padding: 0;
user-select: none;
}
body {
font-family: Roboto;
background: #29313a;
}
.wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.btn {
text-align: center;
width: 440px;
margin-bottom: 10px;
}
.btn .fa {
color: #62d474;
font-size: 30px;
cursor: pointer;
}
.form {
width: 440px;
height: 100px;
padding: 0 20px;
box-sizing: border-box;
}
.input {
width: 400px;
border: 0px;
background: transparent;
box-sizing: border-box;
border-bottom: 3px solid #62d474;
outline: none;
padding: 0 20px 10px;
color: #fff;
font-size: 20px;
transition: all 0.5s ease;
transform: scale(0);
}
#search {
color: #fff;
position: relative;
top: 18px;
left: 90px;
opacity: 0;
letter-spacing: 1px;
transition: all 0.5s ease;
}
#search.active {
opacity: 1;
}
.input.active {
transform: scale(1);
}
#search.move {
top: 60px;
left: 20px;
font-size: 12px;
}
@media screen and (max-width: 640px) {
.btn,
.form {
width: 300px;
}
.input {
width: 260px;
}
#search {
left: 30px;
font-size: 14px;
}
}
/* Fell free to visit my youtube channel for more updates,
https://www.youtube.com/channel/UCtVM2RthR4aC6o7dzySmExA
*/
$(".input").focus(function() {
$("#search").addClass("move");
});
$(".input").focusout(function() {
$("#search").removeClass("move");
$(".input").val("");
});
$(".fa-search").click(function() {
$(".input").toggleClass("active");
$("#search").toggleClass("active");
});
/*
It has been a while since I wrote a article. So I was thinking from many days to write down a new article, finally I came up with a Expanding Animated Search box using Jquery. In this article, we are going to see the totally two different Expanding Animated search box demos.
Before getting into the code, let me explain what's happening in the above gif, first, we can see the search icon and when we click it, an input field pops out below the search icon with a label message(Enter Your Email Address) in it. and when we try to enter the Email address in the input field, the label message moves away from the input field and gets placed below the input field.
For achieving the above demo I’m going to use the scale method of the transform property and Jquery Toggle method.
For Search Icon, I’m going to use the font-awesome icons. and for accessing the font-awesome icons, first, we need to include the CDN link in the head section of the HTML Document.
HTML Structure
Let's get started by creating the wrapper div element with btn and form div elements. and place the search icon within the btn div element. create the label and input field elements inside the form div element. here Label message acts as a placeholder message.
CSS Structure
First, I'm going to reset the default margin and padding values of all HTML elements to zero and set the user-select:none to prevent the user from copying the content on the site.
Now Style the Wrapper div element in such a way that, it should always be in the center of the browser. by setting its position value to absolute(Relative to the browser), top and left values to 50% and by using translate method of transform property, place the wrapper div exactly in the center of the browser by removing the negative margins.
Style the search icon, before that style its parent btn div element, by setting its width and margin-bottom values. and use the text-align property to place the icon horizontally in the center. Now increare size of the icon by using font-size and change its color.
Give width and height values to the form div element. set the padding and use the box-sizing:border-box property, so that the padding value is included into the total width(40(padding-left + padding-right) + 400 = 440).
Set the input fields width, border value to zero, as we required only border-bottom. set the background-color value to transparent and 3pixels of the solid border-bottom. and use the outline property to remove the blue line around the input field. increase the font-size and change the color of the text. use the transition property for smooth transition effect.
Now place the label message accordingly, by making its position value to relative. and using the top and left properties.
Using the scale method of the transform property, and set the scale value of the input field to zero. and make the opacity of the label message to zero.
Jquery code
whenever we click the search icon, active toggleclass is added to the label and input elements.
add the move class to the label on focus and remove the move class on out of focus.
*/
Also see: Tab Triggers