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

Div style is not reflecting #49

Closed
orasik opened this issue Jan 25, 2021 · 4 comments
Closed

Div style is not reflecting #49

orasik opened this issue Jan 25, 2021 · 4 comments

Comments

@orasik
Copy link

orasik commented Jan 25, 2021

Hi,
I was trying to align text to the right in a div but looks like styling from <div> is not reflecting.

I used the example you have

<div style="text-align:right;background-color:#f3f3f3">
            <p>Taken from wikipedia</p>
            <img
                src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
                alt="Red dot"
            />
        </div>

Expected result:
Taken from wikipedia and the image should be on the right side.

Actual result:
No impact.

I tried to put the styling in the <p> and its working fine for the text.

Ex:

<div>
            <p  style="text-align:right;background-color:#f3f3f3">Taken from wikipedia</p>
            <img
                src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
                alt="Red dot"
            />
        </div>

Ideally I would like to have one style for the contents inside the div.

@privateOmega
Copy link
Owner

@orasik Unfortunately, there isn't any equivalent of div in OOXML standards, so we skip div as a whole, at present I don't have any alternative suggestions on this other than translate styles to inner elements if possible.

@orasik
Copy link
Author

orasik commented Feb 7, 2021

@privateOmega Thank you for your reply.
I found a workaround and that is by using style="text-align:right" inside <img>
I am happy to add an example and raise a PR if you agree.

@privateOmega
Copy link
Owner

@orasik Well the change that you did was for a very specific case right? i don't think an example of that is required as part of examples, but I guess if you update your entire example along with fix here, that might help as a pointer for new users. I will close this issue, once you post that. Thanks.

@orasik
Copy link
Author

orasik commented Feb 10, 2021

Thanks @privateOmega
My specific case was just to align an image to the right.

Here is the code:

<img src="data:image/png;base64, {content}" style="width:250px;text-align:right" />

text-align is not a valid CSS for <img> but it worked fine when I exported the docx file.

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