Sure! I can help you convert your CSS and HTML code so that it works seamlessly within the Elementor Free version. Since Elementor Free doesn't support adding custom CSS directly to elements, we'll use the HTML widget to embed your custom styles and HTML. Here's a step-by-step guide to achieve this:
Step 1: Prepare the Necessary Resources
-
Ionicons Library: Your code uses Ionicons for the play icon. We'll need to include the Ionicons CDN link to use these icons.
-
Custom CSS and HTML: We'll embed your existing CSS and HTML within the HTML widget.
Step 2: Combine CSS and HTML Code
Below is the complete code you need to add to your Elementor page. This code includes:
- A link to the Ionicons library.
- Your custom CSS (inside
<style> tags).
- The HTML structure for the video section.
<!-- Ionicons CDN -->
<link rel="stylesheet" href="https://unpkg.com/ionicons@5.5.2/dist/css/ionicons.min.css">
<!-- Custom CSS and HTML -->
<style>
.video {
width: 100%; /* Adjusted to 100% for better responsiveness */
max-width: 600px; /* Optional: Set a max width */
height: 400px;
background: linear-gradient(to left, rgba(0,0,0,0.5), rgba(0,0,0,0.5)),
url('https://images.pexels.com/photos/2041629/pexels-photo-2041629.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500');
background-size: cover;
background-repeat: no-repeat;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto; /* Center the container */
position: relative; /* To handle positioning of pseudo-elements */
}
.video ion-icon {
color: #fff;
font-size: 50px;
padding: 20px; /* Reduced padding for better appearance */
background: rgba(255,255,255,0.3);
border-radius: 50%;
cursor: pointer;
position: relative;
z-index: 1; /* Ensure the icon stays above the pseudo-elements */
transition: background 0.3s, transform 0.3s;
}
.video ion-icon:hover {
background: rgba(255,255,255,0.5);
transform: scale(1.05);
}
.video ion-icon::before,
.video ion-icon::after {
content: '';
position: absolute;
border: 15px solid;
border-radius: 50%;
top: -15px; /* Adjusted to align with the icon */
left: -15px;
right: -15px;
bottom: -15px;
animation: animate 1.5s linear infinite;
opacity: 0;
}
.video ion-icon::before {
border-color: #e5a84f;
animation-delay: 0s;
}
.video ion-icon::after {
border-color: #fff;
animation-delay: 0.75s; /* Staggered animation */
}
@keyframes animate {
0% {
transform: scale(0.5);
opacity: 1;
}
100% {
transform: scale(1.5);
opacity: 0;
}
}
</style>
<div class="video">
<ion-icon name="play-outline"></ion-icon>
</div>
Step 3: Add the Code to Elementor
-
Open Your Page with Elementor:
- Navigate to the WordPress dashboard.
- Go to Pages and select the page you want to edit.
- Click Edit with Elementor.
-
Add an HTML Widget:
- In the Elementor editor, click on the plus (+) icon to add a new section or choose an existing section where you want the video component to appear.
- In the left panel, search for the HTML widget.
- Drag and drop the HTML widget into your chosen section.
-
Insert the Combined Code:
- Click on the HTML widget you just added.
- In the HTML Code area, paste the complete code provided above.
-
Adjust Section Layout (Optional):
- To center the video section and make it responsive, ensure that the section containing the HTML widget has proper alignment settings.
- You can set the section's Content Width to Boxed and adjust the Max Width as needed in the Layout settings.
Step 4: Save and Preview
-
Save Your Changes:
- Click the Update button at the bottom to save your changes.
-
Preview the Page:
- Click the Preview button to see how the video section looks and functions on the live page.
Additional Notes
-
Responsiveness: The above code sets the .video container width to 100% with a max-width of 600px. Adjust these values as needed to fit your design requirements. Elementor's section and column settings can also help in making the component responsive.
-
Icon Size and Padding: You can tweak the font-size and padding properties of the ion-icon to better fit your design.
-
Background Image: Replace the URL in the background property with any image of your choice.
-
Interactivity: The current setup displays a play icon with animations. To make it functional (e.g., opening a video in a popup), you'll need to add additional JavaScript and possibly use other plugins since Elementor Free has limitations on interactivity.
Final Thoughts
By embedding the custom CSS and HTML within the HTML widget, you can recreate your desired video component in Elementor Free. This method ensures that all styles are applied correctly without needing access to Elementor Pro's custom CSS features.
If you encounter any issues or need further customization, feel free to ask!