I am designing this for a phone gap application..i want to code this in html..
i have two questions..
Q1)how do i place a text on the image at different positions?
suc as text1,text2,text3,text4 in the image given here.
Q2) how to place it at the centre in the page.i had given
<img src="img/img1.png" style="margin-left:5px;" />
<img align="middle" />
but,this makes no difference.
guidance required.please help.
i have another doubt...after running the program....there is the extension part of the body after the footer...if you drag up....you can see thtat the body that is between the header and footer is extended. and it moves evento the right.
any mistake in the coding?
put them in a Div, then give this Div a background style ;)
the code should be like this:
<div id='container'>
<span> text 1 </span>
<span> text 2 </span>
<span> text 3 </span>
<span> text 4 </span>
</div>
in the css:
#container{background:url(path/to/img) no-repeat scroll 0 0 transparent; background-size:100% 100%; display:block; height:...px; width:...px;}
#container span{width:50%; height:25%;display:block; overflow:hidden;float:left;}
you can add border to the spans, color etc...
You can do that by wrapping image with div and z-index. Your code should look like this:
<div style="position:fixed; top:10px; left:5px; z-index:250; width:ofimage; height:of image;">
<span style="display:block; width:30; height:20; margins if you need; float:left">text1</span>
<span style it accordingly and add float left>text2</span><br>
<spanstyle them as first two>text3</span>
<span>text4</span>
</div>
<img src="your image" style="if any">
Related
Pretty rusty on my HTML and CSS skills, I've done this before at some point but forgotten how to do this.
I have text on the left side of the page, I want an image on the right side of this div next to it, floating there and not disturbing the text formatting.
Text Description.....
Description..........
Description.......... Image Goes About Here
Description..........
Description..........
Does anyone know how to do this off the top of their head? Thank you.
The easy solution is to use display: inline-block to display information next to an image, without having to add inline css.
img, p {
display: inline-block;
}
<img src="image.png" />
<p>
text left
</p>
use padding and float...
I.e.
<div id="container">
<div id="text" style="padding-right: <image-width+few px>">
text text text
text text text
</div>
<img src="<imagesrc" style= "float:right" />
</div>
padding so the text doesn't overlap with the image.
this should give you the desired effect.
After the image, add a div with clear:both to return to use all the dims of the div.
for example
<style type="text/css">
#picture {
float: right;
}
#text {
margin-right: 110px;
}
</style>
edited
What is the best way to have text and then an image with text following? I dont want to use table if possible but I am running into issues with the items breaking onto their own lines.
Below is my code and css so far:
<div id="header_number">
<h2 class="phone_title">Call Us Today!</h2>
<img src="images/phone_icon.jpg" alt="Call us Today"/>
<h2 class="large_num">1-800-555-9999</h2>
</div>
CSS:
h2.phone_title{font: 13px arial;Color:#013173;text-align:left;}
h2.large_num{font:29px arial;Color:#013173;text-align:left;}
#header_number{float:right;height:60px;width:332px;display:inline;}
I thought the display:inline; in the container div (header_number) would line everything up but that didn't work. If needed I can add a class to the img and float everything left if that is my only option.
Now Define your some element display:inline-block; or vertical-align:top
as like this
h2.phone_title, h2.large_num, img
{display:inline-block;vertical-align:top;
margin:0;
}
Now check to live demo
I am trying to position some stuff in 3 columns. The first column has an icon, 2nd column has text, and the 3rd column has an image.
I wish to do this without using the Table tag. Using CSS I have gotten the first 2 columns placed correctly, here is an image:
On the right, I need to add another image, without disturbing the text on the left.
This is my HTML code (stripped down to the basics):
<img src="Images/icon-1.png" />
<span class="content-title">My title 1</span>
<p>
Here is my text ...
</p>
<br />
<img src="Images/Icon-2.png" />
<span class="content-title">My Title 2</span>
<p>
Here is my text ...
</p>
<br />
And the CSS that emulates the table layout:
.content-title
{
font-size: 26px;
font-family: Helvetica,Arial,sans-serif;
color: #363636;
top: -28px;
position:relative;
left:+10px;
font-weight: bold;
}
#content-benefits p
{
margin-left:80px;
top:-30px;
position:relative;
width:325px;
}
My issue is, that I can't figure out how to place my image on the right, without making it's position:absolute;, but if I do that, I have to (AFAIK) use JavaScript to place the images relatively to their corresponding paragraphs.
If you want another image add it to the HTML before the rest of the "section" and then float it right with:
img {
float: right;
}
On another note, why aren't you using heading tags to display your headings?
You could use the css display:table to make it apear using a table take a look at the docs for this found here
Place the image after the titles span end tag
<img src="Images/icon-1.png" />
<span class="content-title">My title 1</span>
<img src="Images/icon-1.png" />
<p>
Here is my text ...
</p>
<br />
if i properly understand your layout i would do this
<img style="float:left; width:80px" src="image/icon-1.png"/>
<div style="width:405px">
<img style="float:right; width:80px"/>
<div style="float:left; width:325px">
<span/>
<p>
...
</p>
</div>
</div>
you wont need the other positioning you used
if you cannot change the markup,
than put width to the span and p and float:left, and put float:right and width to img
putting float automatically converts the element to display:inline-block which mean that it no longer distributes to the free page width, but takes the minimal allowed space (set by width) and stays rectangular. This way it becomes something like a column.
I'm trying to line up some text between two images on its left and right. Why isn't it moving up?
<img src="srchere" /><span style="padding-bottom:10px;">Some text right here!</span><img src="srchere" />
The two images are larger than the text, so it looks like the text isn't aligned and is positioned lower than the images. How do I raise the text up? The code I have above doesn't seem to move the text up.
Thanks.
If you want images to vertically align with text, you need to use:
vertical-align: middle
Note that your padding-bottom might throw this off a little.
Also, if you are not already doing it, you should use an external stylesheet instead of inline CSS.
If you want to adjust manually, this can do
<span style="vertical-align:100%">
increase/decrease the percentage until u satisfy
HTML:
<div>
<img src="srchere" />
<span>Some text right here!</span>
<img src="srchere" />
</div>
CSS:
div {
display:block;
}
img {
height:30px;
width:30px;
}
img, span {
vertical-align:top;
display:inline-block;
}
Try adding align="absmiddle" attribute to the images.
By "up" I assume you mean aligned to the top of the container box. This should do what you want:
<img style="float: left;" src="...">
<p style="float: left;">Filler text. Filler text. Filler text.</p>
<img style="float: right;" src="...">
I always thought that replacing the <center> tag with <div style="text-align:center;"> will get me the same results. Apparently I was wrong.
This is a portion of my HTML:
(you can also see it in action in the page I created for this question :
http://www.catmoviez.com/ErrorPageSO.aspx
<div style="margin: 0 auto; background-color:red;border:5px solid black;margin-top:5px;width:750px;text-align:center;">
<span style="width:560px;padding-right:10px;text-align:left;float:left;">
<h1>Oops... We're sorry.</h1>
<h3>You've just encountered an unknown error. <br /></h3>
This site is a work-in-progress, we have already been informed of the error and will do our best to fix it. <br />
We would be thankful if you could contact us through the appropriate button and elaborate on what caused this error to appear.<br />
<br />
<h3>
You can go back to the <a style="text-decoration:underline;" href="Default.aspx">Home page</a> and continue using Moviez.NET.
</h3>
</span><span style="width:180px;float:left;"><img src="Resources/Images/404.jpg" /></span>
</div>
I want to do 2 things:
Get Rid of the <center> tag while keeping the div in the center of the page.
Make sure the outer DIVs background color and border affect the inner spans.
UPDATE:
Objective 1 is completed.
Time for objective #2.
Use margin: 0 auto; on your enclosing <div>
<div style="margin: 0 auto; background-color:red;border:5px solid black;margin-top:5px;width:750px;text-align:center;">
<span style="width:560px;padding-right:10px;text-align:left;">
<h1>Oops... We're sorry.</h1>
<h3>You've just encountered an unknown error. <br /></h3>
This site is a work-in-progress, we have already been informed of the error and will do our best to fix it. <br />
We would be thankful if you could contact us through the appropriate button and elaborate on what caused this error to appear.<br />
<br />
<h3>
You can go back to the <a style="text-decoration:underline;" href="Default.aspx">Home page</a> and continue using Moviez.NET.
</h3>
</span><span style="width:180px;"><img src="Resources/Images/404.jpg" /></span>
</div>
See it in action.
Reference: CSS: centering things
If you want to simply center the text, you this css style:
text-align:center;
However, if you are looking to center the element or div itself, there are quite
some solutions for that, one being below:
.mydiv
{
margin:0 auto;
}
Or even with something like this:
.mydiv
{
width:300px; // the width can sometimes be ignored based on inherent size of element.
margin-left:auto;
margin-right:auto;
}
Or even with something like this:
.mydiv
{
margin-left:50%;
margin-right:50%;
}
So you see, there can be more possibilities.
Inline content is aligned with text-align, block content is aligned with margins (set to auto for the case of centring). See Centring Using CSS.
if you are trying to center the div on the page, I usually use this method for my main wrapping div to center the page.
making the left positioning at 50% and then margining back left half of the width of the div.
example below.
#mainspace {
position:absolute;
left:50%;
margin-left:-450px;
height:auto;
width:900px;
border:none;
}
Try this, it has worked for me when I wish I still had that
<center>
tag
< p style="text:align-center" > example image or text < / p >