Was fine until recently and now the centre alignment does not work – left and right work just fine, but not centre.
]]>.alignright {
float: right!important;
}
to custom css
]]>.detail-content.single_page p img.aligncenter {
float: none;
margin-bottom: 15px;
display: inline-block;
}
I added in child theme next code and it worked.
.detail-content.single_page p img.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
It would appear this is the problem “100vw” within the style of an image. Remove a ‘v’ or a ‘w’ from this setting seems to resolve the issue.
Here’s a code example:
<div id="attachment_10298" class="wp-caption aligncenter amp-wp-inline-ad925cc1b1f15b9e578d0bdbbf9c63cd"><a href="https://www.sheilds.org/nebosh/"><amp-img class="amp-img wp-image-10298 size-full i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined i-amphtml-layout" src="https://www.sheilds.org/wp-content/uploads/2015/01/nebosh-acc11-500px.png" alt="NEBOSH accredited center 548" width="500" height="200" srcset="https://www.sheilds.org/wp-content/uploads/2015/01/nebosh-acc11-500px.png 500w, https://www.sheilds.org/wp-content/uploads/2015/01/nebosh-acc11-500px-300x120.png 300w, https://www.sheilds.org/wp-content/uploads/2015/01/nebosh-acc11-500px-450x180.png 450w" sizes="(max-width: 500px) 100vw, 500px" style="width: 100vw;"><i-amphtml-sizer style="display: block; padding-top: 40%;"></i-amphtml-sizer><img alt="NEBOSH accredited center 548" class="i-amphtml-fill-content i-amphtml-replaced-content" src="https://www.sheilds.org/wp-content/uploads/2015/01/nebosh-acc11-500px-450x180.png"></amp-img></a><p class="wp-caption-text">Show all NEBOSH courses</p></div>
You’ll notice in two places ‘100vw’ is used.
In a style tag:
style="width: 100vw;"
and within a sizes tag:
sizes="(max-width: 500px) 100vw, 500px"
Files which have this setting are:
I’ve tried editing these files, but struggling with the issue still. Any chance of a fix for this?
Some additional things I notice:
The not quite center align issue only happens when images are relatively small, say a few hundred pixels in width. If a larger image is used this doesn’t appear to be an issue and the image is centered.
The issue doesn’t happen when rotating the viewport; and the image in centered.
I have additional css rules to align center images with attachments and captions properly – these rules are not interfering at all with the generated code from accelerated mobile pages plugin; I removed my custom rules and the problem still occurred.
Any help would be appreciated, but appears to be a bug.
Thanks
]]>Thank you!
Giulia
I’m currently using the free version of the Huge it portfolio gallery, however, when the portfolio seemed to align to the left, leaving a rather odd space of the right side of the content area.how can i justify the portfolio and centered them?
Thank you
https://www.ads-software.com/plugins/portfolio-gallery/
]]>The first image with the caption aligns nicely to the right. The second image at the bottom with no caption is set to aligncenter. But, as you can see, it doesn’t. It also doesn’t alignright either. I can’t get any of the photos (without captions) to align center or right. They all just align left no matter how I’ve set them in either the Image Details or the actual code.
I have added code to the .css file to align the photos with captions and that has worked. I’ve similarly added code for aligncenter et al and that hasn’t. Below is my entire .css file. Maybe some snippet of code is blocking the align styles from working…?
/* apply a natural box layout model to all elements */
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
body{
margin:0px;
padding:0px;
height:100%;
min-height:100%;
width:100%;
}
#container{
position: absolute;
top: 0;
padding: 0;
height: auto !important;
height: 100%; /*for ie6*/
width:100%;
min-height: 100%;
}
/*Float clearing fix*/
.clearfix:after {
content: ".";
display: block;
height: 0px;
clear: both;
visibility: hidden;
}
* html .clearfix {height: 1%;}
/*reset default padding*/
/*img{
padding:0px 0px 0px 0px;
margin:0px 0px 0px 0px;
border:none;
}*/
form{
margin:0px 0px 0px 0px;
}
ul{
padding-left:1em;
margin-left:0;
margin-bottom:0;
}
h1{
margin:0 0 0 0;
padding:0 0 0 0;
}
p{
margin:15px 0 0 0;
}
/* =WordPress Core
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter,
div.aligncenter {
display: block;
margin: 5px auto 5px auto;
}
.alignright {
float: right;
}
.alignleft {
float: left;
}
.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
a img.alignright {
float: right;
margin: 5px 0 20px 20px;
}
a img.alignnone {
margin: 5px 20px 20px 0;
}
a img.alignleft {
float: left;
margin: 5px 20px 20px 0;
}
a img.aligncenter {
display: block;
margin-left: auto;
margin-right: auto
}
.wp-caption {
background: #fff;
border: 1px solid #f0f0f0;
max-width: 96%; /* Image does not overflow the content area */
padding: 5px 3px 10px;
text-align: center;
}
.wp-caption.alignnone {
margin: 5px 20px 20px 0;
}
.wp-caption.alignleft {
margin: 5px 20px 20px 0;
}
.wp-caption.alignright {
margin: 5px 0 20px 20px;
}
.wp-caption img {
border: 0 none;
height: auto;
margin: 0;
max-width: 98.5%;
padding: 0;
width: auto;
}
.wp-caption p.wp-caption-text {
font-size: 11px;
line-height: 17px;
margin: 0;
padding: 0 4px 5px;
}
Anyone see where the issue is?
]]>I’ve never been able to center images.
I added the following code to my site:
img.alignright {float:right; margin:0 0 1em 1em}
img.alignleft {float:left; margin:0 1em 1em 0}
img.aligncenter {display: block; margin-left: auto; margin-right: auto}
.alignright {float:right; }
.alignleft {float:left; }
.aligncenter {display: block; margin-left: auto; margin-right: auto}
But nothing changed even after clearing cache.
Images align left and right without problem. It’s only centering that doesn’t work.
This is an example of my most recent problem: https://nowthinkaboutit.com/2014/02/easily-add-affiliate-link-to-images/
If you can help it would be appreciated. Thanks
]]>I’m attaching my CSS for reference. Note that I’m using CSS with fluid grid layout for mobile.
img.centered, .aligncenter, div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
img.alignright {
padding: 4px;
margin: 0 0 2px 7px;
display: inline;
}
img.alignleft {
padding: 4px;
margin: 0 7px 2px 0;
display: inline;
}
.alignright {
float: right;
}
.alignleft {
float: left;
}
}
The post content sits in a #main div, which is styled:
‘#main {
clear: none;
float: left;
margin-left: 4%;
width: 63%;
}’
Any help would be greatly appreciated!!
]]>