Avoid text flowing around picture - html

I'm writing a chat and i would like to have the incoming messages on the right and the outgoing on the left. Every message has a user picture, name, messages, time.
My problem is that I can't manage to have the text NOT to flow under the picture.
http://jsfiddle.net/4MVd2/2/
My other questions would be then, how to get the picture on the right to be right from the text without changing the order in the HTML and how to get the username aligned with the top of the picture.
Thank you!

.messagetext{
display:inline-block;
}
.incomingMessage img{float:right;}
.outgoingMessage img{float:left;}​
That should get you going. Now you just need to tweak that image, I wasn't sure if you wanted it at the top or bottom, and what not.
http://jsfiddle.net/4MVd2/10/
EDIT: Addressed your image positioning, I didn't see that the first time I read through. This should be what you want.

sorry I entirely missed the question float: right on the css for the image should fix it. http://jsfiddle.net/4MVd2/8/

1) You might want to convert your images to block level elements and give them a high enough bottom border to prevent text from sneaking bellow the images (either way you have a fixed message row height).
.message img {
height: 40px;
width: 40px;
display: block;
}
.incomingMessage img {
float:right;
margin: 0 0 3em 0.8em;
}
.outgoingMessage img {
float:left;
margin: 0 0.8em 3em 0;
}
2) Add a wrapper container around that block of code and float it instead of the image and the message content.

I agree with Chris Sobolewski and learned how to use inline-block from him.One way I used to use is use a class named`clearfix'.
First float your image like this:
.incomingMessage img{float:right;}
.outgoingMessage img{float:left;}​
Then add a class clearfix like this :<div class="message incomingMessage clearfix">
And here is clearfix:
.clearfix:before,
.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
}
/* For IE 6/7 (trigger hasLayout) */
.clearfix {
zoom:1;
}

Related

Floating .field-item image to left of content type rather than centering it In Drupal

I'm relatively new to Drupal and so-so with CSS and am trying to float the image on a particular content type to the left of the content rather than having it center on the page on a row by itself. The purpose of the page is to have a list of items (like a catalog) and have an image to the left with the various descriptive fields to the right.
Using what I've found online I was able to get this on my CSS which almost works but after the first line being properly located to the right of the image the next line appears below the image. I would like all of them to be to the right, next to the image.
Because Drupal is generating the code I don't have the ability to easily change the HTML (though with work this is theoretically possible) but changes in the CSS are simple
.field-item img {
/* Shift "thumbail" images to the left */
/* new code to shift image to the left */
float: left;
padding-right: 10px;
/* -- old code to center image
margin-left: auto;
margin-right: auto;
*/
}
My theme is derived from danland. The page itself can be seen at http://blog.creatingorigami.com/content/eric%E2%80%99s-lotus
Any leads would be greatly appreciated!
Why change html code? This is crap. You can full styling html for use css styles.
I dont know if I understand right. This problem is clearfix hack, your page contains clearfixs.
Fastest solution.Change css property clear from both on value inherit.In system css called system.base.css. Path something as ..(root)/modules/system/.etc
After will be all contains on right side.
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: inherit; /*changed property!*/
visibility: hidden;
}
Comfortable, but not clean solution is violent rewrite property
to the root css style.
.clearfix:after {
clear: inherit !important;
}

How to center pagination?

You can view the page I'm working on here: http://stats.escalatehosting.com/whois.php
The problem I'm having is that I just can't figure out what CSS needs to be changed to center the page numbers located at the top and bottom of the page. I've tried changing everything I can think of but it always ends up off-center when you start clicking to pages with larger numbers...
I'm not really sure what needs to be changed, if anyone has any suggestions, that would be greatly appreciated.
As you commented, center is not a valid value for float property, either you can use left, right or none which is default.
On creative2tables line 167 change your CSS as provided below..
#ct1_pager_container, #ct2_pager_container {
margin-bottom: 15px;
clear: right; /* Not sure if required */
width: 300px;
}
And in the same stylesheet on line 174 change the below as
#ct1_pager, #ct2_pager {
clear: both;
list-style: none;
}
I've changed the above properties to center your pagination, please do check if you are using these id's for any other element as well.
You need to update below Class.
#ct1_pager_container, #ct2_pager_container{
width:100%;
}
#ct1_pager, #ct2_pager{
float:none;
text-align:center;
}
Update only given element. don't update whole CSS. keep everything else as it is.

float left without wrapping in email

I'm styling the mail I send to my clients and I want the image to float but the text shouldn't be wrapping underneath it. I've tried
#left-image {
float:left;
}
#right-text {
display:table-cell;
}
and
#left-image {
left: 0;
position: absolute;
}
#right-text {
padding: 0 0 0 100px;
position: relative;
}
the first code still wraps the text around the image and the second set of codes puts the image on top of the texts. I've been using the second code for my confirmation page before sending and it works as how I want it to but how come my mail comes out differently?
Today I used the align (html) attribute I just wrote
<table align="left"></table>
this solved my float problems.
Why are you mixing methods? Stick to one, either float or use the display table-cell on both elements .
#left-image {
float:left;
}
#right-text {
float: left;
}
#left-image {
display: table-cell;
}
#right-text {
display: table-cell;
}
I presume that you are creating the email with ordinary div tags which is not recommended to achieve cross-platform compatibility. Use HTML email structure with no floats as well as margins and then you can see a browser as well as platform independednt mail. Instead of float:left, you can go for text-align:left if you are using html tables.

expanding Dots pushing link or text down

I created a spanned line with dots to fill in between text of links and phone number, but i cant get it so that if i have to many dots that the text does not go underneath. The problem is on some different brwosers and computers the .... will look fine or it will push it out of the way. How wouldi go about making it so the dots.... would span and the text would not go below the width its supposed to.
<style type="text/css">
#contactInfo {
margin:auto;
width: 480px;
height: auto;
}
</style>
<div id="contactInfo">
<p>Email: .........................................................................info#hereistheemail.com</p>
<p>Phone: ..................................................................................<span class="redBold">888-888-8888</span></p>
</div>
I tried putting less dots buton some browsers it just doesnt look right.
A better way to do what you want is with a definition list. This will semantically present the information you want and not require you to type out a bunch of dots:
HTML
<dl>
<dt>Phone</dt>
<dd>123-4567</dd>
<dt>Email</dt>
<dd>info#email.com</dd>
</dl>
CSS
dl {
/* Adjust as needed. Note that dl width + dt width must not be greater */
width: 300px;
}
dt {
/* The definition term with a dotted background image */
float: left;
clear: right;
width: 100px;
background: url(1-pixel-dot.gif) repeat-x bottom left;
}
dd {
/* The definition description */
float: right;
width: 200px;
}
You can see an example of it here.
You will have to try and create a workaround for this, instead of just using characters.
Some solutions could be using a background image that repeats itself inside some div/span: http://www.htmlforums.com/html-xhtml/t-toc-style-dotted-line-tab-fill-in-html-103639.html
Or you could think of creating a span between the word e-mail and the e-mail address and try to create a border-bottom: dotted 1px black or something equivalent. Or maybe put the information in a table and create one td with that border-bottom.
Another solution would be to check the number of dots needed with some javascript, but this is most certain not robust at all and will not justify-align your content.
So, be creative with a solution. Filling the line with characters is probably not the way to go.
Try this:
#contactInfo {
[ your other styles ]
white-space: nowrap;
}
Another method is with position:absolute
Demo
#contactInfo p
{
position:relative;
}
#contactInfo span,#contactInfo a
{
position:absolute;
right:0px;
}
Edit (cleaned up version)

How to show an image on html page using only css?

I want to show images on the page but I don't want to hardcode the references to the images in html.
Is it possible to do something like:
HTML:
<span id="got-easier"></span>
CSS:
#got-easier { image: url(/i/trend-down.gif); }
(IE6 should be supported)
Yes, use a background image :)
#got-easier { background-image: url(/i/trend-down.gif); }
Remember to set a span to display: block; and set width/height of your image if you use it.
As David Dorward pointed out, if it's an image relevant to the information, it should be included in the document with an <img> tag and alt attribute.
Heya, the common term for it is css Image Replacement technique (or IR). Here are the commonly used methods currently. Just choose any of the two ;)
/* Leahy Langridge Method */
span#imageName {
display: block;
height: 0 !important;
overflow: hidden;
padding-top: 0px; /* height of image */
width: 0px; /* width of image */
background: url(url/of/image.jpg) no-repeat
}
/* Phark Method */
span#imageName {
display: block;
width: 0px;
height: 0px;
background: url(url/of/image.jpg) no-repeat;
text-indent: -9999px
}
In case you want to display the images inline, position:absolute does the trick:
#got-easier {
display:inline;
position:absolute;
width:img-Xpx;
height:img-Ypx;
background:url(/i/trend-down.gif) no-repeat;
}
The only problem with this is that, since the image position is absolute, it will overlay whatever is next to it (in IE6 it might appear behind), and the workarounds that I found to fix this (with both CSS and jQuery) aren't supported in IE6. Your image-container will have to be followed by new line.
This might be useful when, for instance, you'd like to place a (?) image next to a form caption or a button (that usually have nothing next to them) to display help with onmouseover.