Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,347 members, 7,808,216 topics. Date: Thursday, 25 April 2024 at 08:54 AM

Css Quiz: A "tricky" One - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Css Quiz: A "tricky" One (1360 Views)

Write HTML And CSS Codes On Android Devices / Most Confusing And Simple Maths Quiz / How To: Create A Simple Hover Button With Html And Css (2) (3) (4)

(1) (Reply) (Go Down)

Css Quiz: A "tricky" One by yawatide(f): 4:09pm On Apr 28, 2011
Using *CSS only*, how would I center a 50px by 50px image on a page.

Please note: I said CSS only. In other words, no HTML (valign, halign, etc), no Javascript, no nothing other than CSS.

CSS is more efficient anyways.
Re: Css Quiz: A "tricky" One by Nobody: 4:24pm On Apr 28, 2011
Caramba! Now where them CSS boyz? both of us cannot be setting and answering all the quizes. But this is muy bien sha.
Re: Css Quiz: A "tricky" One by OmniPotens(m): 4:29pm On Apr 28, 2011
Where are my margin: 0 auto; padding: 0 auto; for my body in the CSS naa? Find it and tell me pls

But are u talking about the center of the page as in the point 0 of the x and y axis?
Re: Css Quiz: A "tricky" One by yawatide(f): 4:40pm On Apr 28, 2011
@omni:
Let's say you have a page, centered or not is not the issue. On this page you have 2 paragraphs, separated by an image. Let's assume this image is an ad. By default, this image will be left-aligned. Now let's say your manager approaches you and says that the current alignment looks funny and he thinks the best solution would be to center it so you proceed to find a solution for this, via CSS only.

Does this make more sense?

@dhtml:
I agree 100%. Doesn't this pretty much give you a snapshot of the members of this board, with respect to calibre? I have often been tempted to stop visiting and commenting but love draws me back.
Re: Css Quiz: A "tricky" One by Zahymaka(m): 5:21pm On Apr 28, 2011
Wrap it in any tag that's styled with a text-align: center. Lazy man's code:

<p style="text-align: center"><img, ></p>
Re: Css Quiz: A "tricky" One by yawatide(f): 9:05pm On Apr 28, 2011
Zahymaka is back from the dead tongue

Your code may not be consistent across all browsers. For instance, it doesn't work on firefox (or at least the one on my machine cheesy).

I have encountered this issue on many occasion in the past but today I set out to find a once-and-for-all solution. . . and I think I have.

Your solution is going in the right direction, though not quite there yet. Try again wink
Re: Css Quiz: A "tricky" One by emekaD3(m): 9:25pm On Apr 28, 2011
since its 50px by 50px

img.center {   display: block;   margin-left: auto;   margin-right: auto; }
Re: Css Quiz: A "tricky" One by yawatide(f): 9:54pm On Apr 28, 2011
emeka.D:
Very good! Your solution will indeed work across the board.

The key point here is that IMG won't respond to text-align: center because it isn't text. Also, it is an inline image so directly centering it via margin auto won't work either. So you have to first of all convert it to a block element, like you have.

I will give you 99%. Why not 100%? cool

Your inline style could have been better written: margin: 0 auto;

Yep, I know, I am picky but hey, you will be a better developer and will thank me for it in the future cheesy

Time to come up with something even trickier wink
Re: Css Quiz: A "tricky" One by Nobody: 10:49pm On Apr 28, 2011
Muy muy bien!
Re: Css Quiz: A "tricky" One by emekaD3(m): 11:18pm On Apr 28, 2011
cheesy cheesy why does she remind me of my sec sch art teacher

ans= he never gives anyone a full hundred %
Re: Css Quiz: A "tricky" One by Nobody: 12:19pm On Apr 29, 2011
emeka.D.:

cheesy cheesy why does she remind me of my sec sch art teacher

ans= he never gives anyone a full hundred %
you somehow remind me of those small boys in school we have to flog first before they
learn to do it the right way - 100%

(1) (Reply)

Harvard And MIT Are Offering Free Online Courses / Top Web Hosting Companies In Nigeria 2015 / Naija Adsense For Sale

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.