|  01-21-2015, 09:27 AM | #1 | 
| Member  Posts: 17 Karma: 10 Join Date: Nov 2013 Device: None |  Centering Images 
			
			Hi! Is there a problem if I use ... <p class="center"><img src="../Images/Tbl_1_1.jpg" /></p> ... for centering images? FYI, i use ... p.center {text-align: center;} ... in the style sheet. Thank you! Dr. T | 
|   |   | 
|  01-21-2015, 09:43 AM | #2 | 
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | 
			
			No problem that I know of. That's typically how I go about it. Might want to make sure your img tag has an "alt" attribute, though.
		 | 
|   |   | 
|  01-21-2015, 09:46 AM | #3 | 
| Member            Posts: 17 Karma: 18298 Join Date: Jan 2015 Device: Mantano | 
			
			The alt attribute is mandantory. If there is textual replacement for the image, leave it empty (alt="")
		 | 
|   |   | 
|  01-21-2015, 10:52 AM | #4 | 
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | 
			
			is there a plain: p { <style stuff>; } somewhere in your CSS Your p.center class may need to be AFTER that in the sheet.  is it possible that there are 2 p.centers defined? | 
|   |   | 
|  01-21-2015, 03:36 PM | #5 | 
| Wizard            Posts: 4,520 Karma: 121692313 Join Date: Oct 2009 Location: Heemskerk, NL Device: PRS-T1, Kobo Touch, Kobo Aura | 
			
			Also, if you have in your plain p selector text-indent, then you must also set in your center class the text-indent to zero.
		 | 
|   |   | 
|  01-22-2015, 05:54 AM | #6 | |
| Wizard            Posts: 1,876 Karma: 8821117 Join Date: Mar 2013 Location: Rosario - Santa Fe - Argentina Device: Kindle 4 NT | Quote: 
 1. To use: Code: .center {
     width: X%; /* Where X is the width you wish */
     margin-left: auto;
     margin-right: auto;
}Code: <p class="center"><img alt="" src="../Images/Tbl_1_1.jpg" /></p> 2. To use: Code: .center { 
      text-align: center;
      text-indent: 0;
}
.inlined {
     display: inline;
}Code: <p class="center"><img class="inlined" alt="" src="../Images/Tbl_1_1.jpg" /></p>Regards Rubén | |
|   |   | 
|  01-22-2015, 07:11 AM | #7 | |
| Connoisseur  Posts: 67 Karma: 10 Join Date: Apr 2011 Device: Kindle 3, Samsung Tab 4 | Quote: 
 http://www.impressivewebs.com/defaul...html-elements/ | |
|   |   | 
|  01-22-2015, 07:12 AM | #8 | |
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | Quote: 
 | |
|   |   | 
|  01-22-2015, 08:19 AM | #9 | 
| Resident Curmudgeon            Posts: 80,727 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			And this thread belongs in the Sigil forum and not the ePub forum because?
		 | 
|   |   | 
|  01-22-2015, 08:50 AM | #10 | 
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | |
|   |   | 
|  01-22-2015, 09:48 AM | #11 | |
| Wizard            Posts: 1,876 Karma: 8821117 Join Date: Mar 2013 Location: Rosario - Santa Fe - Argentina Device: Kindle 4 NT | Quote: 
  ): https://www.mobileread.com/forums/sho...d.php?t=247587 | |
|   |   | 
|  01-22-2015, 10:51 AM | #12 | 
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | 
			
			So when you said; "that won't work," you really meant; "that may not work with certain buggy rendering software"?    | 
|   |   | 
|  01-22-2015, 05:07 PM | #13 | 
| Wizard            Posts: 1,876 Karma: 8821117 Join Date: Mar 2013 Location: Rosario - Santa Fe - Argentina Device: Kindle 4 NT | |
|   |   | 
|  01-22-2015, 06:41 PM | #14 | 
| Bookmaker & Cat Slave            Posts: 11,503 Karma: 158448243 Join Date: Apr 2010 Location: Phoenix, AZ Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2 | |
|   |   | 
|  01-22-2015, 07:07 PM | #15 | |
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | Quote: 
  Ruben's post led me to believe there was something inherently wrong with the code, is all. And I don't believe there is. The text-align css was properly being applied to the block e!ement 'p' (whose text will display inline). The img tag, as a block-level element that's displayed inline should be centered horizontally by any competent browser/epub renderer out there. But if one has to ensure that things display properly on the widest range of devices out there, then by all means... point out the aberant systems, and the special requirements to make them to behave properly. Last edited by DiapDealer; 01-22-2015 at 07:20 PM. | |
|   |   | 
|  | 
| Tags | 
| centering images | 
| Thread Tools | Search this Thread | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Centering images in iPad mini/iBooks/iOS8 | AlexBell | ePub | 18 | 10-26-2014 12:02 AM | 
| Centering images | perkin5 | Conversion | 8 | 09-19-2014 10:40 AM | 
| Centering Images using object styles | SamL | ePub | 7 | 04-05-2011 01:28 PM | 
| How to do centering | sjohnson717 | Calibre | 15 | 02-28-2010 09:20 AM | 
| centering images with css override? | Amalthia | Calibre | 2 | 03-30-2009 01:53 PM |