Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by DS928
at 2024-07-12 09:27:08
Point:500 Replies:9 POST_ID:828966USER_ID:11866
Topic:
Cascading Style Sheets (CSS);;Hypertext Markup Language (HTML)
I am trying to center an image but it is refusing to do so.
<div id="container" class="space"> <div id="overlay"> <nav> <ul class="menu"> <li class="current"><a href="index.html">Home</a></li> <li><a href="breeding.html">Services</a></li> <li><a href="sale.html">Work</a></li> <li><a href="events.html">Rental</a></li> <li><a href="gallery.html">About</a></li> <li><a href="gallery.html">Press</a></li> <li><a href="contacts.html">Contacts</a></li> </ul> <div class="clear"></div> </nav> </div> <div id="base"> <img src="images/BarTop.jpg"/> </div> <img src="images/Glasses.jpg" class="center"/> </div> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:
Any reason why this is not happening?
The CSS
.space { padding-bottom:300px;"}img.center { display: block;" margin-left: auto;" margin-right: auto;"} 1:2:3:4:5:6:7:8:9:
Author: DS928 replied at 2024-07-13 07:31:27
Thanks that worked. It was driving me crazy!
Accepted Solution
Expert: myderrick replied at 2024-07-12 22:04:56
500 points EXCELLENT
Note that the in the image, the man is not in the center. There is a large space on the right, The image looks centered but the man is not in the center in the image itself.
If you want the image centered on top of the horses, the parent <div> should have elements with width, and margin: 0 auto. Example:
#container {width: xxx; margin: 0 auto;}
Good luck.
MD
Good luck.
MD
If you want the image centered on top of the horses, the parent <div> should have elements with width, and margin: 0 auto. Example:
#container {width: xxx; margin: 0 auto;}
Good luck.
MD
Good luck.
MD
Author: DS928 replied at 2024-07-12 11:43:15
OK I striped down the page.
http://www.davidschure.com/Untitled-1%20-%20Copy.html
Does this maker it easier?
http://www.davidschure.com/Untitled-1%20-%20Copy.html
Does this maker it easier?
Expert: COBOLdinosaur replied at 2024-07-12 11:37:52
The markup is broken... 42 validation errors.
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.davidschure.com%2FUntitled-1.html&charset=%28detect+automatically%29&doctype=Inline&group=0
You have an xhtml doctype, but you are trying to use HTML5 tags, plus it looks like there are structural errors with extra tag endings, and I think the slider is probably the source of most of the warnings,
You need to cleanup the code. It can be XHTML or it can be HTML5, but it cannot be both; because they have mutually exclusive structural specifications.
Cd&
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.davidschure.com%2FUntitled-1.html&charset=%28detect+automatically%29&doctype=Inline&group=0
You have an xhtml doctype, but you are trying to use HTML5 tags, plus it looks like there are structural errors with extra tag endings, and I think the slider is probably the source of most of the warnings,
You need to cleanup the code. It can be XHTML or it can be HTML5, but it cannot be both; because they have mutually exclusive structural specifications.
Cd&
Author: DS928 replied at 2024-07-12 11:14:44
Here is the link.
http://www.davidschure.com/Untitled-1.html
in the meantime I will continue digging.
http://www.davidschure.com/Untitled-1.html
in the meantime I will continue digging.
Expert: COBOLdinosaur replied at 2024-07-12 11:01:09
The width has to be on the image, not the div.
IThe code show all kinds of other CSS and scripting that also interferes with CSS so there is no reliable way of determining what affects the the positioning without a link so we can do diagnostics. Even with that we may find that the problem is an override in scripting, that you will have to find by digging around in the plugin code.
Cd&
IThe code show all kinds of other CSS and scripting that also interferes with CSS so there is no reliable way of determining what affects the the positioning without a link so we can do diagnostics. Even with that we may find that the problem is an override in scripting, that you will have to find by digging around in the plugin code.
Cd&
Author: DS928 replied at 2024-07-12 10:36:11
Mercy. I added a set width and now its on the right! I attached the file for clarity. Just trying to get the image centered not the menu bar at the top. I tried this as well.
Expert: COBOLdinosaur replied at 2024-07-12 09:58:20
Without an explicit width a block element defaults to 100% and margins right and left have no effect. Simple add a width to the rule img.center and it will work fine.
Cd&
Cd&
Expert: duncanb7 replied at 2024-07-12 09:51:39
div tag need to have fixed width for center, you need to chose the width you want , and no need to center img tag
.space {
width:1000px;
margin:0 auto;
}
if not work becoz of different browser , try
.space {
width:1000px;
margin:0 auto;
}
#base {
width:500px;
margin:0 auto;
}
Duncan
.space {
width:1000px;
margin:0 auto;
}
if not work becoz of different browser , try
.space {
width:1000px;
margin:0 auto;
}
#base {
width:500px;
margin:0 auto;
}
Duncan