Trouble using addiontal css in wordpress to center a div class - html

I am having issues centering a div class in the footer of my WordPress website (using a CPO theme).
I want to call the variable I created in HTML and format it using the additional CSS in the theme of my WordPress site.
After creating div class example I want to use auto margins to center the logo using CSS
#example {
margin-left: auto ;
margin-right: auto ;
}
<div class="example">
<div class="ctwg-social">
<a class="ctwg-social-link ctwg-social-facebook" href="https://www.facebook.com/example" title="Facebook"><span class="ctwg-social-icon"></span></a>
</div>
</div>
I've also tried calling <class id="example"> but that didnt work either.

To center an image: make it into block of its own and apply the margin properties to it. Add this to your css:
display: block;

playing with the max-width: #%; worked for me, thank you for the answer Andrew!

Related

How to make links clickable in Bootstrap via mobile?

I have a website that works fine normally but when in mobile mode, all the links (with exception of the navigation) are no longer clickable. Does anybody know how to change this? I'm not too familiar with Bootstrap though I've tried to troubleshoot as much as I can.
Here's the website: http://dominiquehall.com/dom/
Thank you in advance if anybody can help.
Remove the following code from your theme css file (agency.min.css) at line 477:
div {
height: 100%;
}
Or you can override that property by adding the following code in your custom css file:
div{
height: auto !important;
}
The problem in your code is with the property of div having height 100%, thus overlaying all the links. The div containing the image of a person playing guitar is covering the links in mobile mode. The images are hidden but the div still exist.
Another hack is hiding that particular div in mobile mode.
#media screen and (max-width:991px)
{
.target_div{
display: none:
}
}
In your case the target div is:
<div class="col-lg-4 col-md-5">
<div class="fixed">
<img src="./img/dom1.jpg" id="photo" class="hidden-sm hidden-xs" alt="">
View Resume
Equipment List
</div>
</div>
Just add a class name to the above div and a display as none for mobile devices and your site is good to go.

Need to make images responsive in CSS/HTML for custom plugin

I've searched the existing questions and found some similar issues, but the suggestions there didn't solve my problem.
Here is the issue:
We are using the Visual Editor plugin for Wordpress. My boss wanted this plugin to be used for a special promotion area in the header - he wants to display images that are clickable or have a button. I wrote some custom CSS so this plugin will do that. The issue, as you know, is you can't make a link in CSS. So for the background image, I needed a button. However in this particular case there was so much text on the image, a button would not work.
So, I wrote an ID that I could call in HTML. I made a link, called the ID, and then inside the ID I put a text indent that would push the text off the page and the image would be clickable.
The issue here is that for some reason the image would not fully load. It was cutting off height-wise. I had set width: 100%; and height: auto;, but neither of those things worked.
So, I ended up simply inserting the IMG normally, and linking it normally, but now the problem is I need it to be responsive.
I wrote a class called .responsive-image and made the width: 100%; and height: auto; but this still doesn't work.
Do I need to put the responsive image information elsewhere? Do I need to write some other class? I'm at a loss and have looked at this too long at this point.
You can see this header widget right here - 100daysofrealfood.com/carrot-top-almond-pesto-sustainable-almond-recipes/
And if you inspect you can see what I mean about it not being responsive.
Here's what I've written to insert it into the widget:
<div class="days100-background-header-widget"><div class="responsive-image"><a
href="https://www.100daysofrealfood.com/spring-reset-real-food-mini-pledge-
program/?utm_source=headerwidget">
<img src="https://www.100daysofrealfood.com/wp-
content/uploads/2017/04/WidgetHeaderAreaMP2017.png" border="0"
class="responsive-image" alt="Real Food Mini Pledge Program" />
</a>
</div>
</div>
I have the class in there two places. Maybe that's the issue?
Here's the CSS for the main header widget class:
.days100-background-header-widget{
display: flex;
align-items: center;
justify-content: center;
}
Any feedback is really appreciated. Thanks for reading this super long question!!
The problem is not on the image itself, but on the parent <div> with the class of .days100-background-header-widget. It is set to display: flex so that div is not 100%.
If you want to center things on the screen you can use margin: 0 auto on a block element.
.days100-background-header-widget{
display: block;
margin: 0 auto;
}
.responsive-image {
width: 100%;
height: auto;
}
<div class="days100-background-header-widget">
<div class="responsive-image">
<a href="https://www.100daysofrealfood.com/spring-reset-real-food-mini-pledge-
program/?utm_source=headerwidget">
<img src="https://www.100daysofrealfood.com/wp-
content/uploads/2017/04/WidgetHeaderAreaMP2017.png" border="0"
class="responsive-image" alt="Real Food Mini Pledge Program" />
</a>
</div>
</div>

Html validation on obsolete attribute to the <div> element

I am validating my html and I'm trying to fix:
Error: The align attribute on the div element is obsolete
And have tried using
<div style="text-align:center;">
But When removing the previous <div align="center"> and adding this new code, everything floats to the left of the viewport.
The use of this div is to center all content inside it, which contains nav bars, images, text etc.
What else can I try adding to align all this content and remove the mark-up error?
Thanks for reading!
Hope, this helps!
div{
text-align: center;
margin: auto;
}
Try aligning it in CSS
For example:
HTML
<div id="myDiv">My contents</div>
CSS:
#myDiv {text-align:center}
The attribute "align" that you were using is no longer present in HTML5. Use CSS instead: style="text-align:center;" for an inline CSS.

Yotpo <div> widget center

Im using a widget by Yotpo on my website and would like to center it.
Its located in a product-list.tpl so i thought that product-list.css should be the css to speak with the div.
<div class="yotpo bottomLine"
data-appkey="{$yotpoAppkey}"
data-domain="{$yotpoDomain}"
data-product-id="{$product.id_product}"
data-product-models=""
data-name="{$product.name|escape:'htmlall':'UTF-8'}"
data-url="{$product.link|escape:'htmlall':'UTF-8'}"
data-image-url="{$link->getImageLink($product.link_rewrite, $product.id_image, '')}"
data-description="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}"
data-lang="{$yotpoLanguage|escape:'htmlall':'UTF-8'}"
data-bread-crumbs="">
</div>
I did try this one:
.yotpo_bottomline .{
text-align: center!important;
}
But that didnt realy worked.
I have used in-line styling to solve the issue in our collection pages on Shopify.
Use the following code in the <div> preceeding the main data calls from Yopto.
The padding is optional but adds a small gap from the element above.
<div style="margin: auto; width: 50%; padding: 5px;" class="yotpo bottomLine"

CSS - Images side by side in Wordpress

I have tried using the code provided at http://jsfiddle.net/heera/X3b5g/1/, and when I input my own variable names/images in the fiddle it works fine.
But I then put the CSS code into my child theme style.css and the HTML in my page and the images show one on top of the other, not side by side as I need. I'm not using variables that could be clashing and I'm driving myself insane with this - it is something in Wordpress that stops this from working.
.my-side-by-side {
display: inline-block;
margin-left: auto;
margin-right: auto;
height: 50px;
}
#my-button-centred {
text-align:center;
}
HTML:
<div id="my-button-centred">
<a href=""https://itunes.apple.com/us/app/belize-travel-guide-paid/id792977226?mt=8">
<img class="my-side-by-side" border="0" alt="" src="http://hotguidebelize.com/wp-content/uploads/apple-store.png" alt="" /></a>
<a href="https://play.google.com/store/apps/details?id=com.app_belizeguide.layout">
<img class="my-side-by-side" border="0" alt="" src="http://hotguidebelize.com/wp-content/uploads/google-store.png"/></a>
</div>
If I take out the div id and just use the div class, I do get the buttons side by side, but then they are not centred. What am I doing wrong?
Your code is working perfectly in fiddle: right here
Can you check the source code while testing it, and make sure no other styles overwriting it?,
if so try adding !important in the end of overwrited styles
Whenever you use a child theme you have to be mindful of any CSS from the parent theme. You may have to override some things from the parent theme.
some examples might be
margins
padding
position
display
You will have to inspect the element to see every CSS value that is being set that is not in your child theme and find which one(s) are causing it to display improperly.