Is there a way of writing CSS to reduce the file size of a style sheet containing lots of adjoining classes. Example...
body .elementor-2 .elementor-element.elementor-element-949d9dd .elementor-widget-spacer,
body .elementor-2 .elementor-element.elementor-element-427933f .elementor-widget-spacer,
body .elementor-2 .elementor-element.elementor-element-cb8ce37 .elementor-widget-spacer {
margin-bottom: 0px;
}
hey Use :is selector to reduce the code please check. to learn more about it here
body .elementor-2 .elementor-element:is(.elementor-element-949d9dd, .elementor-element-427933f, .elementor-element-cb8ce37 ) .elementor-widget-spacer {
margin-bottom: 10px;
background: red
}
<div class="elementor-2">
<div class="elementor-element elementor-element-949d9dd ">
<div class="elementor-widget-spacer">spacer</div>
</div>
</div>
<div class="elementor-2">
<div class="elementor-element elementor-element-427933f">
<div class="elementor-widget-spacer">spacer</div>
</div>
</div>
<div class="elementor-2">
<div class="elementor-element elementor-element-cb8ce37 ">
<div class="elementor-widget-spacer">spacer</div>
</div>
</div>
If you use the widget spacer in a different position every single widget makes those classes with the different ids. So you can't reduce the classes.
So if you need not write all the classes on the CSS file.
Use this CSS.
body .elementor-widget-spacer {
margin: 0 !important;
}
or
body .elementor-widget-spacer {
margin: 0;
}
It works with all of the spacer widgets on the webpage.
if you are using elementor.you don't need to do it with custom CSS. Elementor has a dedicated control for this. edit the column, select the layout tab to find widget space, and make it 0. Inside the column, your widget gap will be 0.
Before Doing 0
After Doing 0
Or
you are not using Elementor you can go with :is().To learn more about it follow the article Here
Images only in this particular row of my webpage are disappearing when displayed on the iPad mini (768x1024) and the Galaxy Tablet (800x1280). Other content in the section remain visible. Why would this be happening? Is there a quirk with the mobile devices or perhaps an error in my CSS? (On the rest of the page both images and text are displaying properly on mobile devices.)
The (barebones) code for the row is:
<div class="row" id="advertcontainer">
<h2 class="wow fadeInUp adjust" data-wow-delay="0.2s" style="max-width: 100%;display: block;">What's On across the Lakeside Group</h2>
<div class="grid_4 wow fadeIn" data-wow-delay="0.2s">
<div class="imagediv">
<a href=""><img src="image.jpg" alt="image test" />
<div class="transparent_ribbon"></div>
<div class="overlayeventname">Text here</div>
<div class="overlayeventplace">More text here</div>
</a>
</div>
</div>
</div><!-- /row /advertcontainer -->
In my CSS I've set a breakpoint of 768 to hide this entire row:
#media (min-width: 320px) and (max-width: 768px) {
#advertcontainer {
display: none;
}
}
My complete stylesheet can be viewed at http://www.lakesidesurrey.co.uk/css/style.css
This is what it should look like
But this is what is being displayed on the iPad mini and the Galaxy Tablet
You have this rule in your CSS:
.imagediv img {
position: absolute;
z-index: -1;
}
This will move those images behind all regular layers and change their position to the upper left corner of their containers (if they have position: relative). If those parent elements are not transparent, the images will remain invisible.
Plus, if the image size isn't set within the img tag, the size will be 0x0 since there is no defined widthand height --> they'll be invisible...
I'm trying to embed a responsive iframe with a Vimeo video into my website. The issue is, when I load the page, the iframe is too short so it cuts off the video's timeline, pause and play buttons like so:
Previously, I had a margin-top:4.6em; applied to the iframe in my CSS to push the next container below the view, which I removed as I thought it could be the issue. It solve the height problem on the offline site, but the online version still does it.
(offline site)
I'm running it on Google Chrome and my code looks like this:
<div class="row">
<div class="col-md-5 offset-md-4 col-xs-10 offset-xs-1 text-xs-center">
<div class="embed-responsive embed-responsive-16by9">
<iframe height="100%" class="embed-responsive-item" src="https://player.vimeo.com/video/168167917" allowfullscreen></iframe>
</div>
</div>
</div>
and this is my CSS (although, not very relevant):
body {
background-image: url(/img/pic.jpg);
background-size:cover;
background-repeat:no-repeat;
padding-top:70px;
}
.footer {
margin-left:1em;
color:#000000;
font-size:1.5em;
-webkit-text-stroke:.5px #000000;
}
I'm using Bootstrap 4.0.0 Alpha 5 from the current maxCDN, Google and netdna CDNs. Can anybody help me?
I am trying to align YouTube embedded video in the center of the page in my bootstrap page. The size of the video is always the same.
My html looks really simple:
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div>
I tried different solutions from stackoverflow (which addressed just centering a div, not a video) and the best I was able to came up with was this fiddle.
I already tried solution1, solution2, solution3 but with no result. Another partially successful solution was to use:
width: 50%;
margin: 0 auto;
It worked nicely on desktop, but failed on iPad or a phone (the video went partially outside of a screen). How is it possible to center the video properly in desktop/tablet/phone?
An important thing to note / "Bootstrap" is just a bunch of CSS rules
a fiddle
HTML
<div class="your-centered-div">
<img src="http://placehold.it/1120x630&text=Pretend Video 560x315" alt="" />
</div>
CSS
/* key stuff */
.your-centered-div {
width: 560px; /* you have to have a size or this method doesn't work */
height: 315px; /* think about making these max-width instead - might give you some more responsiveness */
position: absolute; /* positions out of the flow, but according to the nearest parent */
top: 0; right: 0; /* confuse it i guess */
bottom: 0; left: 0;
margin: auto; /* make em equal */
}
Fully working jsFiddle is here.
EDIT
I mostly use this these days:
straight CSS
.centered-thing {
position: absolute;
margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
if your use stylus/mixins ( you should... it's the best )
center-center()
absolute()
margin auto
top 50%
left 50%
transform translate(-50%,-50%)
This way... you don't need to know the size of the element - and the translate is based of it's size - So, -50% of itself. Neat.
Youtube uses iframe.
You can simply set it to:
iframe {
display: block;
margin: 0 auto;
}
<iframe style="display: block; margin: auto;" width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen></iframe>
You dont have to put <iframe> in a parent div at all. You can target exactly youtube iframe with CSS/3:
iframe[src*="//youtube.com/"], iframe[src*="//www.youtube.com/"] {
display: block;
margin: 0 auto;
}
I set the max width for my video to be 100%. On phones the video automatically fits the width of the screen. Since the embedded video is only 560px wide, I just added a 10% left-margin to the iframe, and put a "0" back in for the margin for the mobile CSS (to allow the full width view). I did't want to bother putting a div around every video...
Desktop CSS:
iframe {
margin-left: 10%;
}
Mobile CSS:
iframe {
margin-left: 0;
}
Worked perfect for my blog (Botanical Amy).
Using Bootstrap's built in .center-block class, which sets margin left and right to auto:
<iframe class="center-block" width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
Or using the built in .text-center class, which sets text-align: center:
<div class="text-center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div>
<div>
<iframe id="myFrame" src="https://player.vimeo.com/video/12345678?autoplay=1" width="640" height="360" frameborder="0" allowfullscreen> .
</iframe>
</div>
<script>
function myFunction() {
var wscreen = window.innerWidth;
var hscreen = window.innerHeight;
document.getElementById("myFrame").width = wscreen ;
document.getElementById("myFrame").height = hscreen ;
}
myFunction();
window.addEventListener('resize', function(){ myFunction(); });
</script>
this works on Vimeo adding an id myFrame to the iframe
make iframe with align="middle" and put it in paragraph with style="text-aling:center":
<p style="text-align:center;">
<iframe width="420" height="315" align="middle" src="https://www.youtube.com/embed/YOURVIDEO">
</iframe>
</p>
For a fully responsive IFramed YouTube video, try this:
<div class="blogwidevideo">
<iframe width="854" height="480" style="margin: auto;" src="https://www.youtube-nocookie.com/embed/h5ag-3nnenc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
.blogwidevideo {
overflow:hidden;
padding-bottom:56.25%;
position:relative;
height:0;
}
.blogwidevideo iframe {
left:10%; //centers for the 80% width - not needed if width is 100%
top:0;
height:80%; //change to 100% if going full width
width:80%;
position:absolute;
}
<center><div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div></center>
It seems to work, is this all you were asking for? I guess you could go about taking longer more involved routes, but this seemed simple enough.
The easiest way is by adding tag, before , open the tag and then close it after closing . As said by others tag is not supported by HTML5, and even your ide would show an error. I'm using VS Code and yes it shows an error, but if you check your website the video would be in the center. Youtube still understands the tag :)
I'm new to designing web pages. I need to create a page that will have 2 sections.
The first section will have a logo on the top left corner. The second section will be in the middle of the page with some content generated by iframes.
I have put 2 div tags on the page: one for the image and another for content like this:
<div class="logo">
<a href="http://somelink.com/">
<img src=someimage.png'/></a>
</div>
<div class="content">
<iframe src="somepage.php></iframe>
</div>
How can I do it?
Than you
Try something like this:
Fiddle: http://jsfiddle.net/bjfxq/
Use CSS to position your elements. To learn more about styling, try this interactive tutorial:
http://www.codecademy.com/courses/css-coding-with-style/0/1
HTML
<div class="logo"><img src='http://www.w3.org/html/logo/downloads/HTML5_Logo_128.png'/></div>
<div id="content"><iframe src="http://www.stackoverflow.com"></iframe></div>
CSS
#content {
text-align:center;
}
There are a million other ways to do this, but your question was basic, so my answer was basic.
CSS
.logo
{
float: left;
}
.content
{
text-align: center;
}