strange border aroung text of img - html

I have different images on my website, and some of them (PNG images) have a strange grey border around the text part of image, like this:
https://imgur.com/a/yDtM4
The text is inside the image, not separated.
The css/html code of the image is:
#bor_panel {
border-radius: 12px;
border: 2px solid #287396;
padding: 20px;
width: 170px;
height: 170px;
display: flex;
}
<div id="bor_panel">
<img src="images/raro_page/Ampia_Connettivita_B.jpg" id="raro_panel_connettivita" alt="raro robot connettivita" />
</div>
Any idea? It seems a normal img tag...
------EDIT------
This is the original image:
https://imgur.com/a/P9LVm
It seems ok

There is an issue in your image. I opened your original image in the photoshop and found this after zooming the image. There is an gray space in your image around the text.
I have edited your image in photoshop and make a snippet below. Now there is no border.
#bor_panel {
border-radius: 12px;
border: 2px solid #287396;
padding: 20px;
width: 170px;
height: 170px;
display: flex;
}
img{
width:126px;
height: 126px;
margin: auto;
}
<div id="bor_panel">
<img src="https://i.stack.imgur.com/NdgFO.jpg" id="raro_panel_connettivita" alt="raro robot connettivita" />
</div>

It is strange. It is a part of the image you are using. Try using some image editing application to remove that border. It doesn't seem like its due to CSS or HTML

Related

Small gap between image and image border on chrome & edge desktop

I am getting some strange behaviour aligning images within a border on Chrome (Version 93.0.4531.2) and Edge (Version 91.0.864.37) on desktop (Windows 10 20H2, macOS Big Sur 11.3.1). This is not an issue on mobile.
Please refer to the images to see the small gaps. It is very temperamental, since on some cards these appear on the left side, on others on the top, on some on both and on others not at all.
So far I have tried (in various permuatations):
margin: 0
padding: 0
display: block
vertical-align: bottom
vertical-align: top
vertical align: -webkit-baseline-middle
My zoom is set to 100%. Here is the code for my most recent attempt. I am using Vuejs for this project.
vue template:
<div class="card">
<img v-if="image" :src="image" :alt="name" />
</div>
base.scss
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
component scss:
.card {
width: 240px;
margin-bottom: 25px;
img {
width: 240px;
height: 240px;
vertical-align: -webkit-baseline-middle;
object-fit: cover;
border: 1.5px solid black;
}
}
See the behaviour live here: https://www.sableradio.live/shows. Any help would be greatly appreciated, thanks in advance.
you can solve this by simpley remove float number from border css property like this for reff. attaching image screenshot
.card {
width: 240px;
margin-bottom: 25px;
img {
width: 240px;
height: 240px;
vertical-align: -webkit-baseline-middle;
object-fit: cover;
border: 1px solid black;
}
}
I was facing this issue recently.
Although I cannot figure out the root of the problem, I discovered some tricks which you may consider:
setting a background to container, let the bg-color blend into the gap
.card {
background-color: black;
}
OR
negative margin to your photo
img {
margin: -1px;
}
Not pretty, but it works for me.

Use CSS to give my web page a white foreground, gray background (mimic MS Word)

I'm rendering a large document (500 pgs) as a web page. My users are used to Word. Can I use CSS to mimic the look from the image below, a uniform 'page' with a white background with a fixed width, and the rest of their browser showing a gray background? Like the image below, except without the ribbon and all that:
The only think I can think of is to put the entire document inside a massive div tag, but is there a better way? Thanks.
This can be done fairly easily with 2 divs and a bit of css.
I also gave the white a border as per the image.
.container {
background: #9099ae;
width: 100vw;
height: 100vh;
padding: 40px 200px;
}
.content {
background: #fff;
width: 100vw;
height: 100vh;
margin: 0 auto;
border: 2px solid #000;
border-right: 4px solid #000;
}
<div class="container">
<div class="content">
</div>
</div>

How to make a gallery of images automatically fit in close together in HTML/CSS?

Okay, so I have a webpage that has a 'gallery' of images that are all of different sizes (all the same width, though), and they're all fit into image containers with borders, and padding for a little title underneath them. I want them all to fit together snugly so that there's no awkward large space between pictures of different sizes, because right now as you can see in the picture, the webpage seems to want to keep all the images in horizontal rows and not fill up the empty space that's left.
For example, I want two of the images that are not tall to fit into a row next to one that is tall so that all space is being used up.
This is what it looks like: screenshot of the page
This is what the CSS for the gallery looks like: `
.galleryHolder{
text-align: center;
margin-left: 55px;
top: 20px;
}
div.gallery {
margin: 30px;
border: 2px solid darkgrey;
float: left;
width: 400px;
display: block;
}
div.gallery:hover {
border: 2px solid crimson;
border-radius: 2%;
opacity: .4;
}
div.gallery img {
width: 100%;
height: auto;
}
div.title {
padding: 5px;
text-align: center;
Font-family: Century Gothic;
Color: crimson;
}`
and here is what a sample of the HTML for each image looks like:
<div class = "galleryHolder">
<div class="gallery">
<img src="images/ForPurchase/purchase11.jpg" alt="Snowy Owl Landing" width="320" height="400">
<div class="title">"Snowy Angel"</div>
</div>
</div>
Is there a possible way to make all these images fit into all possible gaps to make everything look snugly put together? Answer would be greatly appreciated, this is for a project that is due in a few hours.

Cannot add background image to my <div>

I have a div with more buttons and I cannot add an image to it.
Html:
<div class="menu_border" style="height: 460px; width: 290px;">
</div>
CSS:
.menu_border {
float: left;
border: 5px groove;
margin-left: 70px;
text-align: center;
background-image:url('images\generale\bkgmenu.jpg');
}
My css and source codes are in the main folder. There is the folder images->generale and the images. I've tested the path, is correct. I've tried to add the image as normal <img> and it worked.
It does not work as background.
ur code needs to change like this
background-image:url('images\generale\bkgmenu.jpg');
to
background-image:url('images/generale/bkgmenu.jpg');
image will taken this format

Image before text in one div

Is it possible to put image (css content property) before text inside div in my case?
JavaScript inserts different messages into the element with msgBox. And unfortunatelly I cannot touch JS.
Also text must be in the center (in the middle of the picture).
Requirements:
Message text is in the center
Between image and text strongly 10-20px
Div must not contain other elements
Text and icon should be centered.
document.getElementById("msgBox")
.innerHTML = "Here can be any text any long";
#msgBox {
border: 1px solid black;
padding: 10px;
text-align: center;
}
<div id="msgBox">(icon) text</div>
You could try it with css :before:
#msgBox:before{
content: url('path/to/your.png');
}
http://jsfiddle.net/a4utqvh1/1/
You can achieve this by setting height and verticle align:middle css of image and put image before text.
Here is the updated fiddle
http://jsfiddle.net/a4utqvh1/2/
You can use :before in css to add your icon as a background image, so even if you change the content of your div in JS, the icon will still be there.
#msgBox:before {
content: "";
display: inline-block;
width: 10px; // width of your image
height: 10px; // height of your image
background: url('img.jpg'); // path to your image
}
Here is the fiddle using image as a background image
msgBox {
border: 1px solid black;
padding: 10px;
text-align: center;
background: url(http://png.findicons.com/files/icons/2015/24x24_free_application/24/error.png) no-repeat 5px center;
}
http://jsfiddle.net/a4utqvh1/4/ will this work
You can use the background-image-Attribute form a div-Element.
#msgBox {
...
background-image: url('http://png.findicons.com/files/icons/2015/24x24_free_application/24/error.png');
background-repeat: no-repeat;
background-position-y: center;
...
}
A Sample with nice padding:
http://jsfiddle.net/bronni/a4utqvh1/7/
may this will work, put image tag in innerHTML text
document.getElementById("msgBox").innerHTML = "<img src='http://png.findicons.com/files/icons/2015/24x24_free_application/24/error.png'/> <span>Here can be any text any long</span>";
#msgBox {
border: 1px solid black;
padding: 10px;
text-align: center;
}
<div id="msgBox">(icon) text</div>
http://jsfiddle.net/a4utqvh1/3/
.wrapper {
border: 1px solid black;
padding: 10px;
text-align: center;
float: left;
}
.wrapper img,
#msgbox {
float: left;
}
<div class="wrapper">
<img src="http://png.findicons.com/files/icons/2015/24x24_free_application/24/error.png" />
<div id="msgBox">(icon) text</div>
</div>