How can I shrink a <div> to its content, while still having it centered?

1 Answer

Answer :

answer:Maybe you should try a <span> instead of a div… that should shrink to it’s width by default. (Or you could give your div display:inline;). To make a div not stretch, I think you need to give it a width, in either px or %, but that doesn’t sound like what you want.

Related questions

Description : Do you think its about time to drop further development for IE6?

Last Answer : I think it's still too early, there's a good portion of people still using it. I would guess we have another couple years of supporting it, so best to find fixes for the common issues ... users before making that decision. Others shared their thoughts here - Web Developers: Do you still support IE6?

Description : Why does my tumblr homepage always end up going to a page called "Zynga RewardVille"?

Last Answer : answer:This is what I’m seeing: http://i53.tinypic.com/2emlaib.png I don’t see anything about Zynga. It could very well be you’ve got a bug on your side.

Description : Anyone know of a good free website hosting site that allows .css files?

Last Answer : answer:Not sure if I'm understanding you correctly, but the css file would just be linked from the html files you've made. So it's not that you'd make your content files into css files, you'd ... doesn't support css files. Does that help? Am I misunderstanding? Perhaps a link to the site would help?

Description : One more time... what am I doing wrong now with this CSS?

Last Answer : What do you want to do with your CSS? I need to see an example of what’s happening now, and then know what you want it to do diferently. Given that, I’ll try to help.

Description : How to put a scrollbar in my tumblelog?

Last Answer : Not familiar with Tumblr, but perhaps you could try overflow: scroll instead of overflow: auto?

Description : When I try to put my scrollbar in my tumblelog, none of my posts show up. What am I doing wrong?

Last Answer : View the source Here

Description : Holiday CSS themes - when and what?

Last Answer : We change things around when we feel like it, or when a user gives us a compelling reason to (as I explained in this blog post).

Description : How To Add An Image Around My Tumblr Audio Posts?

Last Answer : You'd have to use custom HTML, and then look for look for the specific part of code in their theme (both the image section near the beginning), and also HOW to place it in the second part of the ... sure which image you want to use in your tumblr, so not sure how to help you out with specifics.

Description : Coding A Theme For Tumblr Is The Same As Coding AnyOther Blog Right?

Last Answer : i didnt mispelled anything tho

Description : I'm not sure how my site is rendering on screens with a height greater than 900px. Could you take a look?

Last Answer : looks fine to me at 1080 full screen.

Description : Creating your own wordpress theme?

Last Answer : You have to know css and a bit of HTML and PHP. (don't be intimidated by the PHP part) it isn't that bad once you know what it is doing. Themeing wordpress is kinda hard. Going from zero to themeing wordpress ... try to convert it into a theme. No promises. And I won't try to get it to work in IE.

Description : CSS Question: What to do with fonts if the user end doesnt have it on their computer?

Last Answer : Currently this is basically only available in Webkit-based browsers such as Safari and Chrome. This is a touchy subject with a lot of designers. Your best bet is sIFR which uses Flash and JavaScript to ... doing those, just specify back up fonts. Like so: font-family: Helvetica, Arial, sans-serif;

Description : Any suggestions as to where to look for information on how to edit CSS in Squarespace?

Last Answer : Learn CSS?

Description : Is there a way to have multiple versions of Internet Explorer installed?

Last Answer : Try using Multiple IE. It won't work in Vista unfortunately though.

Description : Does anyone use CSS sprites?

Last Answer : I hadn't read about it before. From what I can see now, it looks like quite a neat trick, but I can't really think of many use cases (or, for that matter, real-life situations where this effect is used but reached in another way).

Description : Some vertical alignment help using CSS would rock my socks.

Last Answer : Try adding margin-top: 9px; to each of the images. I haven’t tested this on IE6, but it works on Firefox 2 and Safari 3.

Description : Navigation bar doesn't appear in Safari...

Last Answer : answer:I tested it and it looks just like Firefox… http://www.indielyrics.info/pics/safari.png

Description : Safari Image Mouse Overs

Last Answer : I did FIRST 8 years ago… good luck with your robot. Your buttons (Georgia, Lego, Keynote) look correct on my Safari (Safari 3.0.4 on OS X Leopard)... no flickering or underlining.

Description : A JavaScript question. [more inside]

Last Answer : answer:I can’t answer the question directly. But here’s a CSS-only solution that allows for that functionality, I think: http://cssglobe.com/lab/tablecloth/ Scroll to the bottom of the article to change the settings so , for instance, only table rows highlight when moused over.

Description : What's the deal with Opera and width?

Last Answer : Have you set the padding and margin for both the divs and the images? And why don’t you just use overflow: hidden? Or perhaps overflow: visible?

Description : Should I add my own CSS to my tumblelog?

Last Answer : Google is your friend. Search for a beginners css tutorial

Description : RapidWeaver for pro web dev?

Last Answer : answer:I use RW 4 even though there are a lot of snazzy and polished templates, the editing of the code is still the same as would be in any HTML editor feature (as in DW), so in the ... self-paced online course through Lynda.com (not a plug). Just some personal perspectives from a current RW user.

Description : Guestbook thingy.

Last Answer : answer:nah, but I would go to google and servh for it. Or you can go to this websites forum and it has a shoutbox and if you want something like that I know the admin, Zlools, who could give you come ... Click forum at the top and take a look at the shoutbox. It should be near the top of the forum.

Description : How to position a div above another div while placed after that div? (see descr.)

Last Answer : I saw this the other day. Look for the fourth tip. Not sure if that is exactly what you want but you might want to take a look.

Description : Soils containing organic matters (A) Are of spongy nature (B) Swell with decrease of moisture (C) Shrink with increase of moisture content (D) None of these

Last Answer : Answer: Option A

Description : Tumblr code issue for DoinWork theme Utralite: this should be HTML basics but it's giving me some complicated problems with tricky between posts?

Last Answer : The above it has a bottom margin of 100 pixels, which is pushing it way down. I think you probably would want to transfer most or all of that bottom margin to the DIV the comments are supposed to go in.

Description : A question about CSS and DIV alignment?

Last Answer : answer:Drop a clear: both; on your div for the footer/bottom. #bottom { background:url(“images/bottom.png”) no-repeat scroll 0 0 transparent; clear:both; height:21px; position:relative; width:959px;

Description : Styling Multiple lines of text in a div?

Last Answer : You use HTML to structure the document. To tell the browser what is the point of each block of text. This is a heading , This is a paragraph , etc. You use CSS to tell the browser how each of ... : smaller; font-style: italic; } p.newsstory { font-face: courier } p.comment { font-size: smaller }

Description : DIV class & id name parser for automatic CSS file generation?

Last Answer : I saw something on reddit today about something called HSS, I can’t remember the link but google it, it sounded like it does what you want.

Description : What's the best way to force a div to extend to the bottom of a page?

Last Answer : Hmmm I typed up a big thing and then realized the whole thing is fluid. Fluid designs are one of those noble undertakings that rarely work out without a lot of thought and testing. Line lengths get ... and it should still force your containing div to go full height. I hope it helps and have fun.

Description : Can I put a SPAN inside a DIV?

Last Answer : answer:Not sure if this will work (a demo page would be nice), but it often does. Add the following line to your CSS for .container: overflow: auto; Also note that you do not need to enclose them in a – you already have the element which is also inline as opposed to block-level like s.

Description : Div help?

Last Answer : answer:I got a page not found error. Check your link? EDIT…if you make it .html lowercase it works.

Description : CSS issue.

Last Answer : Hmm… not quite sure what you mean… whatever it is, I wonder if you’re taking the complicated option? It certainly seems like you are. Perhaps try simplifying your layout.

Description : Which equation will be true, if the medium is considered to be air? a) Curl(H) = 0 b) Div(H) = 0 c) Grad(H) = 0 d) Div(H) = 1

Last Answer : b) Div(H) = 0

Description : Which of the following identities is always zero for static fields? a) Grad(Curl V) b) Curl(Div V) c) Div(Grad V) d) Curl(Grad V)

Last Answer : d) Curl(Grad V)

Description : Find the correct relation between current density and magnetization. a) J = Grad(M) b) J = Div(M) c) J = Curl(M) d) M = Curl(J)

Last Answer : c) J = Curl(M)

Description : Choose the best relation. a) A = -Div(V) b) V = Curl(A) c) H = -Grad(V) d) V = Div(E)

Last Answer : c) H = -Grad(V)

Description : The relation between flux density and vector potential is a) B = Curl(A) b) A = Curl(B) c) B = Div(A) d) A = Div(B)

Last Answer : a) B = Curl(A)

Description : Find the Maxwell law derived from Ampere law. a) Div(I) = H b) Div(H) = J c) Curl(H) = J d) Curl(B) = D

Last Answer : c) Curl(H) = J

Description : Find the Maxwell equation derived from Faraday’s law. a) Div(H) = J b) Div(D) = I c) Curl(E) = -dB/dt d) Curl(B) = -dH/dt

Last Answer : c) Curl(E) = -dB/dt

Description : It cannot be determined from Gauss law, whereas the remaining options can be computed from Gauss law. 10. Gauss law for magnetic fields is given by a) Div(E) = 0 b) Div(B) = 0 c) Div(H) = 0 d) Div(D) = 0

Last Answer : b) Div(B) = 0

Description : If a function is said to be harmonic, then a) Curl(Grad V) = 0 b) Div(Curl V) = 0 c) Div(Grad V) = 0 d) Grad(Curl V) = 0

Last Answer : c) Div(Grad V) = 0

Description : The point form of Gauss law is given by, Div(V) = ρv State True/False. a) True b) False

Last Answer : a) True

Description : The curl of curl of a vector is given by, a) Div(Grad V) – (Del) 2 V b) Grad(Div V) – (Del) 2 V c) (Del) 2 V – Div(Grad V) d) (Del) 2 V – Grad(Div V)

Last Answer : b) Grad(Div V) – (Del) 2 V

Description : Identify the correct vector identity. a) i . i = j . j = k . k = 0 b) i X j = j X k = k X i = 1 c) Div (u X v) = v . Curl(u) – u . Curl(v) d) i . j = j . k = k . i = 1

Last Answer : c) Div (u X v) = v . Curl(u) – u . Curl(v)

Description : The Laplacian operator is actually a) Grad(Div V) b) Div(Grad V) c) Curl(Div V) d) Div(Curl V)

Last Answer : b) Div(Grad V)

Description : A CRO screen has ten divisions on the horizontal scale. If a voltage signal 5 sin 314t+45 deg)is examined with a line base settings of 5 msec/div, the number of cycles of signal displayed on the screen will be a) 0.5 cycles b) 2.5 cycles c) 5 cycles d) 10 cycles

Last Answer : Ans: 2.5 cycles

Description : What is the output of the following code AX = 37D7H, BH = 151 decimal DIV BH a) AL = 65H, AH= 94 decimal b) AL= 5EH, AH= 101 decimal c) AH= E5H, AL= 5EH d) AL= 56H, AH= 5EH

Last Answer : b) AL= 5EH, AH= 101 decimal

Description : IDIV and DIV instructions perform the same operations for? a) Unsigned number b) Signed number c) Signed number & Unsigned number d) none of above.

Last Answer : b) Signed number

Description : n 8086 microprocessor the following has the highest priority among all type interrupts. a) NMI b) DIV 0 c) TYPE 255 d) OVER FLOW

Last Answer : a) NMI