Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image in CSS with "content"-attribute #211

Closed
ghost opened this issue Apr 19, 2018 · 7 comments
Closed

Image in CSS with "content"-attribute #211

ghost opened this issue Apr 19, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2018

Hello,

I have the problem, that in the generated PDF I don't see the images, which I addes in css:

Example 1:
.toc:before { content: url(../img/test/logo.jpg); }

Example 2:
@bottom-left { content: url(../img/test/logo.jpg); }

When I test it in html I see the image, so the code should be correct, but in the generated PDF there are no images. When I put only text in the "content"-Attribute I see this text in pdf, but image not.

Have you an idea for the issue?

Best regards,
Fabian

@danfickle
Copy link
Owner

Hi @kuhlware

We don't currently support the url function in the content property. However for your page margin example, you could use a running element as demonstrated in #201

PS. Please leave this issue open as it is something we should support.

@ghost
Copy link
Author

ghost commented Apr 24, 2018

Hi @danfickle,

okay thank you! I have the problem, that I should have to show an image in pdf. It also doesn't work if I put an image in html. There is always a blank space. Do you know what's the problem? I want to do this as a hotfix, until you implement the "url()"-Problem, but doesn't work, too.

<img src="https://test.de/test.jpg"/>

@danfickle
Copy link
Owner

It should work, unless you are also running into #212 ?

@hbcondo
Copy link

hbcondo commented Mar 8, 2020

Hi, this issue is a couple years old but I wanted to follow-up and see if there was any progress made in supporting the url function in the content property. Thanks.

danfickle added a commit that referenced this issue Mar 8, 2020
Working but with content images behaving as blocks rather than inline-blocks.
@danfickle
Copy link
Owner

Hi @hbcondo,

I just implemented images in the content property. Unfortunately, despite my best efforts the images are behaving as blocks rather than inline-blocks. This probably is just annoying to me and not a practical issue since you would only run into it if you are adding other content items in the same content property.

content: "Hello " url(world.png); /* Works */
content: url(hello.png) " World!"; /* Incorrect layout, the world will be below hello.png rather than beside it. */

@hbcondo
Copy link

hbcondo commented Mar 8, 2020

@danfickle is the man! This is a nice addition to an already great library. Thanks for the quick reply and commit; looking forward to seeing the PR and release for this.

@danfickle
Copy link
Owner

OK, now images specified in the content property list act correctly as inline-blocks rather than blocks. This feature will be released with the next release.

For best results, you may need to specify the box as inline-block also:

#three::after {
    display: inline-block;
    border: 2px solid pink; /* Optional border */
    background-color: orange; /* Optional bg color */
    /* Multiple items may be specified in the content list */
    content: url(../../demos/images/flyingsaucer.png) "..." url(../../demos/images/flyingsaucer.png);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants