Image size has more than 100% witdh
See original GitHub issueI’m trying to render the entire html where it has p, a, img
tags, but the images seems to be cropped instead be shown as 100% width.
I tried add img
style, like normal css, but without success.
const styles = StyleSheet.create({
a: {
color: style.content.link.color,
fontWeight: '300',
},
p: {
color: this.props.data.color,
fontSize: this.props.data.fontSize,
lineHeight: this.props.data.lineHeight,
marginBottom: 0,
marginTop: 0,
paddingBottom: 0,
paddingTop: 0,
},
});
<HTMLView
addLineBreaks={false}
value={this.props.data.item.content}
stylesheet={styles}
/>
Is there anything to fix this?
"react-native": "0.57.4",
"react-native-htmlview": "^0.13.0",
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Make an image width 100% of parent div, but not bigger than ...
Just specify max-width: 100% alone, that should do it.
Read more >Why do we use maximum width 100% to see a full image and ...
Go with min-width: If we take the example above and we have a picture that is 640x400, min-width: 100% will make the images...
Read more >Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >Why setting max-width: 100% prevent an image from larger ...
Literally, setting max-width of an image to 100% should mean the width of the image cannot be greater than the width of its...
Read more >Sizing items in CSS - Learn web development | MDN
The first image has been given width: 100% and is in a container which is larger than it, therefore it stretches to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just add renderNode attribute in HTMLView tag like this
<HTMLView
value={this.state.content}
stylesheet={styles}
renderNode={this.renderNode}
<-- this line/>
Copy and paste renderNode function with your custom stylingrenderNode(node, index, siblings, parent, defaultRenderer) {
if (node.name == 'img') {
const a = node.attribs;
return ( <Image style={{width: 100, height:100}} source={{uri: a.src}}/> );
}
}
I did a workaround to solve this issue and it is working fine