I'm trying to make a masonry layout possible through using (placing this in the page content section):
[gallery size="large" link="file" columns="4" ids="1,2,3"]
Documentation: https://codex.wordpress.org/Gallery_Shortcode
But even though this is the desired effect:
This is what keeps happening:
Essentially, if there was some CSS or even javascript that could be added to transform the gallery to do this, would be fantastic.
My code at the moment, looks like this:
<div class="gallery-template">
the_content();
</div>
And my additional css is:
.gallery-template img{
max-width: 100%;
height: auto;
border: none !important;
}
.gallery-item{
width: 33% !important;
margin: 0;
margin-top: 0 !important;
}
This doesn't exactly do anything to solve the problem of when a new section of thirds starts, to get rid of the padding and margin between the "rows".
When the [gallery] shortcode mentioned above gets rendered, the way it's rendered in the DOM is like so:
<div class="gallery-template">
<div id="gallery-1" class="gallery">
<dl class="gallery-item">...</div>
<dl class="gallery-item">...</div>
<dl class="gallery-item">...</div>
// And so on..
</div>
</div>
And the CSS rendered in the DOM is:
#gallery-1 {
margin: auto;
}
#gallery-1 .gallery-item {
float: left;
text-align: center;
}
.gallery-item {
width: 33% !important;
margin: 0;
margin-top: 0 !important;
}
Has anyone implemented a solution for this sort of obstacle yet?
Also, I'm trying to refrain from using an external plugin.
This is, indeed, a css question. I would suggest checking out flexbox. Creating an entire solution for you will be a little tricky since you haven't posted your html, so if this exact code doesn't work, try editing your post to include some of it.
#gallery-1 {
display: flex;
flex-direction: column;
}
.gallery-item {
flex: 0 1 33%;
margin: 0;
margin-top: 0 !important;
}
OK! I was able to get this working. Here's my solution:
First, it was necessary to prohibit the gallery shortcode to inject external styles into the page. So in the funtions.php file, I added:
add_filter( 'use_default_gallery_style', '__return_false' );
Next, I took out the column specification in the shortcode tag I was incorporating in the page, like so:
[gallery size="large" link="file" ids="1,2,3"]
Rather than:
[gallery size="large" link="file" columns="4" ids="1,2,3"]
Lastly, I placed this CSS into my page (including the column-count):
.gallery-template{margin:auto; column-count:4;column-gap:0;}
.gallery-template img{max-width:100%;height:auto;border:none !important;}
.gallery-item{margin:0;display:inline-block;width:100%;width:100%;margin-top:0;}
EXTRA: If you are looking to make this responsive, simply add the #media tags where you want your preferred breakpoints, and place in the new number of columns, like so:
#media screen and (max-width:1200px) {
.gallery-template{column-count:3;}
}
#media screen and (max-width:772px) {
.gallery-template{column-count:2;}
}
Related
Edit: Apologies, forgot to add the sandbox to tinker: https://codesandbox.io/s/inspiring-wing-tekl08
I'm having an issue with my CSS. To clarify, the reason I want to do this is because I want my text to have a mix-blend-mode: difference on h1 within a media query, and after researching on here and other forums I've concluded that it's only possible if the background image which the text blends with is inserted via CSS instead of an <img/> in my React Component. If this is possible in any other way and I'm going about this wrong, feel free to give me a better option.
For some reason, the background image that I've inserted (see code below) is placing itself in front of h1. I've tried setting a z-index: 1 on the image and position: relative - z-index:something>1 on the text but it doesn't seem to work. Same goes for the <Nav/> tag that can be seen in the component - it ends up hidden behind the image.
Component:
const PageHeader = () => {
return (
<motion.div
id="header"
variants={imgFade}
initial="hidden"
animate="show"
className="bg-image"
>
<div className="header-container">
<div className="title-container">
<motion.h1
variants={textAnimate(0.7)}
initial="hidden"
animate="show"
>
FNAME
</motion.h1>
</div>
<br />
<div className="title-container">
<motion.h1
variants={textAnimate(0.8)}
initial="hidden"
animate="show"
>
SNAME
</motion.h1>
</div>
<Nav />
</div>
</motion.div>
);
};
export default PageHeader;
CSS:
.bg-image {
background: url("img/compressed/Website\ Cover_Open_NoBG.png") no-repeat
bottom right;
background-size: contain;
width: 100%;
height: 100%;
float: right;
}
.header-container {
margin-left: 100px;
margin-top: 200px;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.title-container {
overflow: hidden;
}
h1 {
font-family: "Lato";
font-size: 5rem;
font-weight: 300;
vertical-align: middle;
text-align: left;
mix-blend-mode: color;
pointer-events: none;
}
Apologies if it's blaringly obvious - again if someone can find an alternative to do the code below then I would much rather follow through with that:
#media screen and (max-width: 1200px) {
.h1 {
mix-blend-mode: difference;
}
Thanks!
UPDATE: This has been solved by just putting position: relative; z-index: 2 on .header-container. Perfect example of stopping coding after 3am or else you get blinders on and can't see the obvious answer.
In case anyone can help regarding mix-blend-mode: difference do let me know.
UPDATE 2: Second issue solved! Had to put a background color of white on the background property and also put the mix-blend: mode on .header-container - Text had to be changed to white and kept on difference blend even on a white backdrop.
im using wordpress oceanwp theme to create my ecommerce website. Im using medium header sytle for m website. however, i wan my mobile screen to show a different header style of "minimal".
So is used the custom css code to fix this. However, the arrangement in header are (logo/cart icon/menu). But what i expected is rearrange it's position to (menu/Logo/cart icon).
#media only screen and (max-width: 959px) {
.top-header-wrap.clr {
width: 50%;
}
.bottom-header-wrap.clr {
width: 50%;
}
div#site-header-inner {
display: flex;
}
.oceanwp-mobile-menu-icon.clr.mobile-right {
height: 100%;
line-height: 100px;
}
}
Is there any css code the can help me to solve problem. I expected to get my mobile size screen's header with the arrangement of (Menu/Logo/Cart Icon)
Thank you!
can you Please send the html code how they are now
or
You have to put the code like this
.header{
display: flex;
align-items: center;
justify-content: center;
}
.header div{margin:0 10%; text-align:center;}
<div class="header">
<div>menu</div>
<div>logo</div>
<div>Cart</div>
</div>
refer this for flexbox ordering.
Use display flex for parent class of header elements and custom order can be specified like this :
.box :nth-child(1) { order: 2; }
I am building a website with WordPress. On my homepage I want a picture grid (10 x 3) of different products, and when you hover over each picture, a caption with the product name will pop up.
I have managed to do 3/4 of it but there's this massive white space below each row. :(
I am using the SiteOrigin editor widget to insert the image, and using HTML and CSS to code the hover effects. See below for the current coding.
HTML:
<div id="pic">
<img class="hover" src="http://peacefruit.net/wp-content/uploads/2016/11/Hassaku.png" />
<p class="text">Summer Mikan</p>
</div>
CSS:
.text {
color: #000000;
font-size: 16px;
font-weight: bold;
text-align: center;
background: rgba(255, 255, 255, 0.5);
}
#pic .text {
position:relative;
bottom:80px;
left:0px;
visibility:hidden;
}
#pic:hover .text {
visibility:visible;
}
Here's the website so you can see what I've done: http://peacefruit.net
The top row has the captions, but also, the pesky gap. The bottom three rows are examples of how I want it to look (no borders or gaps between pics). All rows and individual widgets have no padding, margins or gutters and I've already adjusted the theme padding to 0 with CSS.
I'm sure it's a simple line of code I'm missing, but it's driving me crazy!
Please send help.
Try adding to your inline css for siteorigin-panels-stretch
overflow:hidden;
height:164.89px;
Hope this works.
Thanks!
In your case
the id should be unique.
So, it is better to change #pic to a class
Also, the <p> tag in your style contain padding-bottom and it will case the white space problem.
Change each pic to the following
HTML:
<div class="pic">
<img class="hover" src="http://peacefruit.net/wp- content/uploads/2016/11/Hassaku.png">
<div class="text">Summer Mikan</div>
</div>
CSS:
.pic{
position: relative;
}
.pic .text{
position: absolute;
top: 80px;
width: 100%;
visibility: hidden;
}
then it should be work.
Stylesheets for WordPress themes can have a lot of CSS bloat, so you're on the right track creating a custom stylesheet, to tackle the styling nuances you desire.
Since this is a responsive theme, it's best to begin solving this from a mobile-first perspective.
The first thing to prune is the bottom-margin: 30px; for .panel-grid-cell, like this:
.home #main .panel-grid-cell {
margin-bottom: 0;
}
The next thing is to correct your HTML mark-up. The value of pic is given to multiple id attributes. An id attribute is used to denote a unique element. The class attribute denotes a non-unique element. pic should be assigned to class attributes instead, since many elements in your layout utilize this hook value. Like this:
<div class="pic">
I'm noticing that img.hover and p.text are getting wrapped in an unnecessary <p> tag. Make sure that this does not happen in the SiteOrigin editor.
You should then prune the bottom-margin: 1.5em for paragraphs inside of the .pic divs (note the designation of pic as a class hook .pic, rather than an id hook, which would have been #pic):
.pic p {
margin-bottom: 0;
}
To get even closer, relative positioning should be used on the .pic div to ensure that the subsequent styling suggestion (position: absolute;) will take effect:
.pic {
position: relative;
}
And then, for the text that appears when hovering an image:
p.text {
position: absolute;
width: 100%;
}
The styles above will work for mobile, but your theme is responsive, and you might need to account for some styling variations with different screen sizes.
For tablets, you'd need a media query like this:
#media (min-width: 600px) {
.some-class {
some-property: some-value;
}
etc...
}
And finally, for desktop:
#media (min-width: 1000px) {
.some-class {
some-property: some-value;
}
etc....
}
Thanks everyone for your help :) After some fiddling around with the suggestions and a software update, there is no gap now!
I thought I'd post my final code in case anyone has a similar problem and it might be of some help. (Note: there are some minor style changes which differ from the original post but have no effect on how it works).
HTML:
<div class="pic">
<img class="hover" src="http://peacefruit.net/wp-content/uploads/2016/11/Summer-Mikan.png"/>
<div class="text">Summer Mikan</div>
</div>
WIDGET CLASS:
fade
CSS:
.fade {
-webkit-opacity: 0.6;
-moz-opacity: 0.6;
opacity: 0.6;
}
.fade:hover {
-webkit-opacity: 1;
-moz-opacity: 1;
opacity: 1;
}
.pic {
position: relative;
}
.text {
color: #FFFFFF;
font-size: 22px;
font-weight: bold;
text-align: center;
background: rgba(214, 187, 14, 0.85);
}
.pic .text {
position:absolute;
top: 0px;
width: 100%;
visibility:hidden;
}
.pic:hover .text {
visibility:visible;
}
.pic p {
margin-bottom: 0px;
}
So glad it finally works, much appreciation to everyone!
I have created a wordpress single theme, but I am getting confuse with CSS code, where CSS rules should change the display to make menu and image slider revolution look closer.
I would like to reduce the space between the main navigation menu and my revolution slider
This is my website url: http://www.warungrempong.com/
I am trying to use this CSS code:
.admin-bar .nav-container {
min-height: 0;
}
But it's not working as desired and only work when I am using it on my browser dev tools.
When I try to change in my website, nothing happen.
How can I solve this issue?
Thanks.
In the style.css file of your active child theme (or theme), You should add this:
.nav-container {
min-height: inherit !important;
}
When looking at the generated source code of your home page, it seems that your theme is embedding some CSS rules in the html document, as you have this (on line 41 of that source code):
<style id='ebor-style-inline-css' type='text/css'>
nav .pb80 {
padding-bottom: 0px;
padding-top:0px;
}
.pt120 {
padding-top: 0px;
}
.nav-container { /* ==========================> HERE ONE TIME */
min-height: 0;
}
.logo { max-height: 300px; }
.nav-container { /* ======================> HERE ANOTHER TIME
As this is the last instance, it get the priority on first one! */
min-height: 491px;
}
.admin-bar .nav-container {
min-height: 523px;
}
#media all and (max-width: 767px){
.nav-container {
min-height: 366px;
}
.admin-bar .nav-container {
min-height: 398px;
}
}
</style>
So may be you have add this CCS rules yourself somewhere in your theme settings. The best thing, should be to remove that 2 repetitive CSS rules, and your issue should get solved without any need…
I have a page with lots of data, tables and content.
I want to make a print version that will only display very few selected things.
Instead of writing another page just for printing, I was reading about CSS's feature for "#media print".
First, what browsers support it? Since this is an internal feature, it's OK if only the latest browsers support it.
I was thinking of tagging a few DOM elements with a "printable" class, and basically apply "display:none" to everything except those elements with the "printable" class.
Is that doable?
How do I achieve this?
EDIT:
This is what I have so far:
<style type="text/css">
#media print {
* {display:none;}
.printable, .printable > * {display:block;}
}
</style>
But it hides everything. How do I make those "printable" elements visible?
EDIT:
Trying now the negative approach
<style type="text/css">
#media print {
body *:not(.printable *) {display:none;}
}
</style>
This looks good in theory, however it doesn't work. Maybe "not" doesn't support advanced css ...
Start here. But basically what you are thinking is the correct approach.
Thanks, Now my question is actually
becoming: How do I apply CSS to a
class AND ALL OF ITS DESCENDANT
ELEMENTS? So that I can apply
"display:block" to whatever is in the
"printable" zones.
If an element is set to display:none; all its children will be hidden as well. But in any case. If you want a style to apply to all children of something else, you do the following:
.printable * {
display: block;
}
That would apply the style to all children of the "printable" zone.
If you want to display some links etc. when in the browser, that you don't want to be printed. Furthermore you have some logos and letterhead info that only should go on the printed page.
This seems to work fine:
Example:
CSS:
#media print {
.noPrint {
display:none;
}
}
#media screen {
.onlyPrint {
display: none;
}
}
HTML:
<div class="noPrint" id="this_is_not_printed" >
<a href=links.html>
</div>
<div class="onlyPrint" id="this_is_only_seen_on_printer" >
<img scr=logo.png >
<img scr=letterhead.png >
</div>
A simple way:
<style>
.print-only{
display: none;
}
#media print {
.no-print {
display: none;
}
.print-only{
display: block;
}
}
</style>
I got here because I was curious about printing a chart generated by chart.js. I wanted to just print the chart directly from the page (with a button that does a 'window.print') without all of the other content of the page.
So, I got closer by using the technique from the answer here: Why can't I override display property applied via an asterisk? .
You have to apply the 'asterisk' to the 'body' element, not just by itself. So, using the example CSS that the OP (Nathan) added to the question, I changed it to this:
<style type="text/css">
#media print {
body * {display:none;}
.printable, .printable > * {
display: block !important;
}
}
</style>
Then adding that 'printable' class to the chart itself, as in
<canvas id="myChart" class="printable" width="400" height="400"></canvas>
Which removed all page elements on the printed output except the chart when the 'print' button is clicked (via this):
<script>
myChart.render();
document.getElementById("printChart").addEventListener("click",function(){
window.print();
});
</script>
So, perhaps this will help anyone that gets to this question via the googles.
Came across the same question recently and for me, this solution works just perfect:
#media print {
* {
visibility: hidden;
}
.printable {
visibility: visible;
position: absolute;
top: 0;
left: 0;
padding: 10mm;
}
.printable * {
visibility: visible;
}
}
Since visibility: hidden doesn't remove elements, as display: none does, it is possible to change it for desired elements separately.
Nearly all browsers support it. It might be advantageous to use the media attribute on the link tag.
Using display: none; in some of your rules would be an appropriate way to handle your situation.
I suggest to hide the element that you won't print:
HTML
<h1 class="no-print" >Welcome Just Screen</h1>
<div> I want print this section :)</div>
<div class="no-print">It's display only on screen</div>
CSS
#media print {
.no-print {
display: none;
}
}