How to define top margin for widgets - css

I am configuring the widgets for my wordpress site but I would like that these start to be visible after 1200px (for example). It is like to have a margin between the first widget and the top menu of 1200px but I do not find the way to achieve this behaviour.
If you wanna see a real example you can go to this post:
https://www.thetravelerlens.com/tutorial/photoshop/enfocar-photoshop
The widgets must appear right after the black and thin line divider (where the social icons are).
Thanks a lot for all your help in advance.

I'm not sure which widget you are referring to. If you're talking about the "ENFOCAR IMAGEN EN PHOTOSHOP" and "Lo más destacado de este artículo" sections, then the correct way to achieve this would either be to check in your theme documentation if there are other widget areas you can use, or move the widget area where you want it to be displayed via php and a child theme (which I think you're already using) or use CSS, but not just with margins.
Find other widget area
By the look of it, you're using this theme. It's no longer available so I couldn't check a working demo, but by looking at the screenshots on the page, there may be other widget areas you can use. See screenshot below:
See red rectangles in the screenshot
I suggest you read your theme documentation to see if you can use those, but generally speaking, you can:
Go on a single post, and click on Customize in the top admin bar.
Click on Widgets and you should see a list of all the available widget locations on this page. Add the widget in different locations and check if another one fits your needs better. If you can't find anything, then check the solution below.
Move widget area
Locate a file called single.php or single-post.php in your parent theme and duplicate it into your child theme.
In this child theme file, locate the widget area in the code, it should look like this dynamic_sidebar( 'some_identifier' );. Take this code, and move it to the desired location in the page template.
Reload your page and check if it is placed correctly. You'll likely need to remove additional elements on the page to remove the top section and add CSS in the style.css file of your child theme to add some styling to the new widget section
Please note that this is just general instructions and each theme is different so it may differ for yours.
Moving the whole widget area using CSS
You could also move the whole widget area using CSS. If there aren't any better widget locations and you're not too comfortable playing around in php, this may be the best solution.
With flexbox:
This is a more modern approach but has less cross-browser support. You should also add vendor prefixes for better support.
First, we'll apply flexbox to the parent container:
.single-post #tve_editor {
display: flex;
flex-direction: column;
}
Then we'll change the order of the section with the social media icons to place it first, before all the other elements:
.single-post .thrv_symbol_72533 {
order: -1;
top: -49px; //Little fix for the CSS Thrive builder applies
}
With absolute positioning:
This solution has a bit more cross-browser support but will require more CSS tweaking on your end, mostly for responsive behavior with media-queries (which I'm not going to get into details here).
First, we will add a margin at the top of the widget section that is exactly the height of the section with the social media icons:
.single-post #tve_editor > .thrv-page-section.tcb-window-width {
margin-top: 115px !important;
}
Then we'll move the section with the social media icons at the top of the page using absolute positioning:
.single-post .thrv_symbol_72533 {
position: absolute;
top: -114px;
}
Once done, you need to check the responsive behavior and apply CSS tweaks using media queries to adjust the layout for all cases.
Adding margins to current widget:
Again, I'm not sure if you're really referring to the top section with the dark backgound image, but if that is the case, here are the reasons why it's not a good idea to simply add CSS margins to this section:
1200px high is not a fixed distance you can move your widget and that will work on all screens. Your theme is responsive, therefore this height will change depending on the device. For example, it will be much taller on a mobile device.
The height of the widget also depends on its content. If you have more text on another post, it will be taller so you can't just apply a margin of a specific height and hope it to work in all cases.
You would still need to create an empty space below the section with the social media icons that is tall enough to receive the widget section. However, since the height is dynamic, you can't just set a value for its height.

Related

How to Flex items vertically in Elementor Woocommerce Products

after hours of failing in CSS code to find a solution i am reachingg out for help! 😀
A common issue i find with woocommerce (wordpress, elementor)
is with the widget “products” which is an Elementor widget.
Some of my products have more than 1 line of title, causing the items in other container and the same line look bad (not flexing all over the container vertically)
Well i assume its not a great explanation so i added
i just want the button that says “Buy now” (not in english :D) to stick to the bottom of the column.
Thanks, Ben
The cause of the uneven buttons is the difference in height of the item titles. A simple solution is to add custom css in your themes customizer or in elementor to force a min height of the title to ensure its always the same height.
Adding this to your custom css will fix the alignment for you
.woocommerce-loop-product__title{
min-height: 100px;
}
You can experiment with the height to find the ideal one. 100px is just a quick recommendation that appeared to be working well.
See attached image for example.

Elementor Widget Sepparation problems

I'm using elementor for the first time and I can't remove the space between widgets, you can see the small line of 8px in gray colour with a gradient inside (thats my picture). When I put this picture Elementor adds the white space above and below the line, I thought this is added only at desing time but when I update and see in the browser the whites spaces continues here. Of course the picture in the media gallery don't have this white spaces... I don't know what to try, the only trick is to force the margins but then when the screen changes it's overlapped (this is not a solution). I think Elementor should place the picture without nay margin, only the picture. I have the next properties set:
Content: Full Width
Elementor Widgets Space: 0px
Columns Gap: no gap
All margins and paddings: none (0px)
Tried height to default and forced to 8px
I have two ideas that might help you:
check for a border, maybe you set it on accident or it got imported
take a look at your custom css. Sometimes plugins like envato elements add their custom css without you noticing
It's also a good idea to use your browser and inspect the element to find out if there is any gap. You can also try that on the elements next to the widget you are using.

Wordpress facebook comment plugin is displayed on top

have a small problem with facebook comments. For some reason my theme is not very compatible with the plugin.
If you click to inspect the element, it will fix on it's own then (no idea why).
Also I would like if you add more text into the comment box the content below the box doesn't move down. So is there a way to align the box correctly only with the css? ( I have tried 2-3 different plugins, but I had the same problem)
Website: http://www.viskasseimai.lt/
P.S. it works great on a singple post, but something is wrong inside the home page...
Plugin used: https://wordpress.org/support/plugin/facebookall/page/3
The problem lies in the absolute positioning of the .blog-grid elements. The position and top values are explicitly declared and set as inline styles before the facebook comment box is appended to the element. So these calculations don't factor in the additional element because they occur before it's introduced.
CSS
.blog-grid.element.column-1.masonry-brick {
position: relative !important;
top: auto !important;
}
The above rules will over-qualify the inline rules for every instance of the element since the !important declaration has been used.
If you want these rules to only apply to the home page, add .home as a preceding selector before .blog-grid, same methodology would apply to archive pages or specific taxonomy type pages.

CSS percentage width resize based on window

This probably was answered somewhere, but I can't find it :s
My question is about dynamic resizing of divs based in percentages.
Please look at code example below for the examples and possible solutions I made.
I ask if there is a better way to do resizing?
More detailed explanation:
Say I am writing a plugin that people can insert in their pages. (Imagine login form).
I go ahead and design the plugin's divs. I use media queries to achieve desired look for different devices. I work on a div straight inside of a 'body' element.
I use percentages for design (I like percentages). Say I set div to 80% width.
Now I give this plugin to the user. User goes ahead and puts the plugin's div inside of another
div that is 100px in width. Now everything looks awful. (80% of 100px is not a lot [80px]).
And of course I want user to put my plugin inside of whatever small-width divs that he have.
The solutions I saw so far to this problem was to create a holder div of certain width - say hardcode 300px. (ex - jQuery UI's Datepicker div; Meteor's login widget div). And then code to it always knowing the 300px width that I set before is not going to change.
But I don't know how good of a solution this is.
Moreover if I decide to go with hard-coding width, my plugin would need width of ~ 1000px. Because I want div to resize with media queries.
And if I go with hard-coding width (say holder div of 1000px width) and put it on a page, the page will have horizontal scrolling. And you cannot simply hide holder div (parent div) and have child to show at the same time. So this requires setting position:relative for holder (parent) div, putting it outside of window, and use same for child div - position:relative with same offset in opposite direction of parent offset.
I hope I am being clear so far and have not confused you!
A code example to illustrate what I am talking about:
http://jsbin.com/ifawez/18/edit
#cimmanon's comment cleared things out for me.
The problem is with lack of HTML/CSS "tools" available at the moment. Since responsiveness came into play fairly recently there are not a lot of CSS-native tools to accommodate changes in dimensions.
For instance media-queries exclusively work with width of window/document and not of other elements such as divs.
The solution I currently employ is using Javascript to determine width of a div and resize accordingly.
What I resize is the number of columns I want to display (I use Multi-Column module as suggested by cimmanon) which is pretty stable on webkit browsers. Since it is all done in Javascript (and jQuery's Sizzle) I keep an array of sizes like so:
var widthArray = [
{min:0, max:250, columns:1, secondary:false},
{min:251, max:350, columns:1, secondary:true },
{min:351, max:479, columns:1, secondary:true },
//more div sizes
];
// more code here
$(element).css({
"column-count": object.columns,
"-moz-column-count": object.columns,
"-webkit-column-count": object.columns
});
This is sort of like media-queries, but allows to work with width of html elements, not screen size alone.
Additionally I follow the way jQuery UI displays its components: using position relative/absolute.
.outer_div {
position: relative;
}
.inner_div_with_elements {
position: absolute;
z-index: 1010;
width: 99%;
float: left;
overflow: hidden;
...
}
.inner_components_displayable {
position: relative;
display: block;
}
.inner_components_hidden {
display: none;
}
So in Summary:
Media queries alone work with size of screen, and resizing of any inner element can be done in percentages to the screen size. They can be of huge help, but you turn into making your components work either with percentages based off screen, or specifying something like min-height and !important (as suggested by #Octavian)
Javascript manipulation of elements is currently easier, but is a costlier alternative (jQuery SIzzle is pretty slow)
A lot of libraries (ex. jQuery UI) use Javascript together with position relative/absolute to make sure their components/plug-ins will work nicely on all users' screen sizes.
I ended up combining position with javascript to emulate media-queries and multi-column design at the same time for responsiveness.
Thanks everyone who participated!
If I am reading this correctly, the main issue here is that it can potentially become too small based on where the code is located.
So why not just add a min-width property with !important? That way you can still base the size off of the parent container, but be sure that it doesn't get too small and ugly.
Potentially, you could even have a script to base the width off of the parent div and the min-width off of the screen size.

Wordpress Plugin - How can I make the text responsive, OR replace it with a new div?

http://bit.ly/YqiQNQ
I have this food menu that looks great online. The menu is generated by a Wordpress plugin with customizable CSS. The rest of the site looks mint on the iPhone, but when you get to the menu it overlaps awfully and kind of disappears.
Open the link in the menu and make your window size really small - see how it overlaps at the smallest setting?
I was playing with #media on the widths and couldn't figure it out.
Can anyone help me make the text wrap around at the websites smallest width?
Or a plugin that will detect if the user is on mobile and display a different page entirely (just that page).
If you're having an issue with text not wrapping how you'd like it to wrap I'd suggest adding white-space: normal to the text's parent element to ensure that the text will wrap and not inherit a white-space: nowrap declaration intended for another element.
For your specific circumstance, the following CSS will force the menu to wrap appropriately:
.rmc-menu-wrap {
white-space:normal;
}

Resources