Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By webdev100 on
Hi,
I am simply trying to have image as td background and have some text in the td cell.
Here I have the below code to have two td cells(1 row) with background image and some texts. I am getting repeating images with two texts.
How can i have two images(400 width each) with texts?
<table width='100%' border='0' cellspacing='1' cellpadding='0'>
<tr><td width = '400' background='../image1.jpg'>This is our text1 over the img</td>
<td width = '400' background='../image2.jpg'>This is our text2 over the img</td></tr>
</table>
Thanks.
-D
Comments
I am guessing you want width=
I am guessing you want width='400px' (notice the px).
Also as a best practice, it is better to assign a css id or css classes to elements and then use a style sheet to apply the css
Definitely CSS would be
Definitely CSS would be better. For now, I am just trying to fix it in html.
I did change width = '400' to '400px'. It did not solve it. Any help?
Thanks.
I think that using an
I think that using an external style sheet, as nevets mentioned, is the better approach.
Meanwhile place
td { background-repeat:no-repeat; }
in a css file or inlinestyle="background-repeat:no-repeat;"
in each of the td.Thanks for help. I am getting
Thanks for help. I am getting closer.
Now I have this code.
If I save this code in notepad as html and run it locally, I get the result I want which is to display the text with the image background.
But If i run the same code in drupal (structure >block>add block > FULL HTML option is selected), the text is outside the image. I am lost
Please advise with html for now.
-D
In your latter example, you
In your latter example, you only have a td (with a 250 width).
Two questions. What is the size of your image? What theme are you using?
There may be other styles in conflict here. You should inspect the page with Firefox firebird or Chrome inspector.
I am using Bartik theme.
I am using Bartik theme.
Image size = 299 x 166
I just used chrome inspector and noticed that style.css > text-align was set to center. I changed to Left. Problem is fixed.
Thanks for your help.
Glad i could be of help.
Glad i could be of help.