I need to compress an input type date, so i've tried setting the width to 120px.The problem is that there's a space between the date numbers and the input date icon.
I need to decrease or remove that space:
Is there a way to do that?
My code (I'm using bootstrap 4 btw):
<input type="date">
You can use:
::-webkit-calendar-picker-indicator{
margin-left: 0px;
}
If this is not enough, and you want even less space, just put a negative margin, like in this snippet:
::-webkit-calendar-picker-indicator{
margin-left: -15px;
}
<input type="date" >
Note: This works in Chrome. Firefox (and possibly other browsers) may not show the icon by default.
You can target the icon by using the following css selector: ::-webkit-calendar-picker-indicator
To increase the margin, use:
input[type=date]::-webkit-calendar-picker-indicator {
margin-left: 100px;
}
<input type="date">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
To decrease the space, use a negative margin, or any other option.
Correct way to use icons on <input type="date"
with bootstrap 4
Boostrapt icon calandar : https://icons.getbootstrap.com/icons/calendar/
sample code:
input[type="date"]::-webkit-calendar-picker-indicator {
position : absolute;
left : 0;
margin : 0;
width : 2em;
transform: translateX(-2.5em);
opacity : 0;
}
form { margin:1em }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" />
<form>
<div class="form-row align-items-center">
<div class=""> <!-- col-sm-3 my-1-->
<div class="input-group">
<div class="input-group-prepend">
<label for="DteInput" class="input-group-text">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/>
</svg></label>
</div>
<input type="date" class="form-control" id="DteInput" placeholder="">
</div>
</div>
</div>
</form>
of course, you have to fight a bit for the chrome icon interference
see:
Method to show native datepicker in Chrome
Method to show native datepicker in Chrome
Related
Basically have the right section of the navbar reserved for text/an alert that will be placed there depending on if certain things happen. But, the alert, even when invisible, changes the height of the navbar. How do I fix this?
It might be hard to tell with the images but there's definitely a difference with the popup and when it's closed.
This is using the latest bootstrap v5.2.3
.navbar-brand img {
height: 50px;
width: 50px;
}
.alert svg {
height: 20px;
width: 20px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" />
<nav class="navbar navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#">
<img src="https://via.placeholder.com/100" alt="Bootstrap" width="30" height="24">
</a>
<span class="navbar-text text-dark" id="wallet_address">
<div class="alert alert-warning d-flex align-items-center alert-dismissible fade show" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>
<div>
<strong>ERROR!</strong> No Wallet detected.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</div>
</span>
</div>
</nav>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js"></script>
edit: updated css and bootstrap version
It doesn't look like the alert is affecting anything while it's invisible. The alert has 1rem of margin on the bottom, which calculates out to make the entirety of the alert 90px tall. The available space of the nav by default is less than 90px, so including the alert in that space forces the nav to expand to accommodate the alert. Note the yellow area (margin) in the image.
The reason your nav has a height larger than expected when the alert is missing is because the navbar-brand class has some top and bottom padding, probably coming from bootstrap. Note the purple area (padding) in the image.
I copied this card template from bootstrap for a warning card. At the header of the card, I'm using an svg that I got from Bootstrap's icons https://icons.getbootstrap.com/icons/exclamation-triangle-fill/. There, you can see some examples where the icon is implemented properly. The icon is aligned exactly in the middle next to the next. However, in my code the icon is aligned at the bottom and so is not centered. Is there a way to fix this?
<div class="card" style="width: 18rem;">
<div class="card-body">
<div class="mb-3">
<h5 class="card-title">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 5zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
</svg>
Warning
</h5>
</div>
<p class="card-text">
Text of card
</p>
</div>
</div>
Use negative margin-top to adjust it.
For example:
<div class="card" style="width: 18rem;">
<div class="card-body">
<div class="mb-3">
<h5 class="card-title">
<svg class="myIcon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 5zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
</svg>
Warning
</h5>
</div>
<p class="card-text">
Text of card
</p>
</div>
</div>
CSS:
.myIcon { margin-top: -5px; }
Check it here: https://jsfiddle.net/8t61qehn/
printf("%d\n", 42); /* You can simply add some css on style part in as follows: */
.card-svg {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
}
.card-txt{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
/*And add this styles as classes on your HTML code as follows: */
<img class="card-svg" src="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 5zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
<img>
<h5 class="card-txt">Warning</h5>
/By the way i changed the svg into img you can try like that if this is what you want./
My Result
Just change first DIV style with text-align: center
Check the image from above make sure that way you want show
drop like if work for you.
I am using Bootstrap 4's SVG icons in my buttons. I have the code working with the SVG hardcoded into the page's HTML. Now I want to refactor the SVG into a CSS class. I have followed the Bootstrap 4 instructions for creating the CSS class but I cannot work out how to display the icon on my button. I've tried a lot of variations without success.
CSS:
.bi::before {
display: inline-block;
content: "";
background-image: url('data:image/svg+xml,<svg width="2em" height="2em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"><path fill-rule="evenodd" d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"></svg>');
background-repeat: no-repeat;
background-size: 1rem 1rem;
}
HTML:
<a href="#" class="btn bi" role="button" download></a>
Your help is greatly appreciated.
Well, to make your code work, there is a couple of note you should consider it.
First off, the <path> element within your SVG does not have any closing tag, so it will produce an error in the data attribute and it will prevent the icon to be shown.
To make your SVG responsive friendly it and fill the available space in the container it is better to avoid using width and height directly in the SVG element and use preserveAspectRatio="none" instead.
It is better to encode your SVG element instead of putting it directly within the data:image/svg to provide a valid string format for cross browsing purposes. You can use tools like this for the cause.
According to the above notes, your final code should be something like this:
.bi::before {
content: "";
display: inline-block;
background-image: url('data:image/svg+xml,%3Csvg%20preserveAspectRatio%3D%22none%22%20viewBox%3D%220%200%2016%2016%22%20fill%3D%22currentColor%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20d%3D%22M.5%209.9a.5.5%200%200%201%20.5.5v2.5a1%201%200%200%200%201%201h12a1%201%200%200%200%201-1v-2.5a.5.5%200%200%201%201%200v2.5a2%202%200%200%201-2%202H2a2%202%200%200%201-2-2v-2.5a.5.5%200%200%201%20.5-.5z%22%20%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20d%3D%22M7.646%2011.854a.5.5%200%200%200%20.708%200l3-3a.5.5%200%200%200-.708-.708L8.5%2010.293V1.5a.5.5%200%200%200-1%200v8.793L5.354%208.146a.5.5%200%201%200-.708.708l3%203z%22%20%2F%3E%3C%2Fsvg%3E');
background-repeat: no-repeat;
width: 2rem;
height: 2rem;
}
<a href="#" class="btn bi" role="button" download></a>
NOTE: You can also create an SVG file in your project and then directly refer to it in your background image property like regular images for easier usage.
You can add an tag inside the or tag and apply the class to it. You can try to do it without the pseudoclass. Also you can adjust the icon in the button adding padding to the button.
the same question here.in my case i used this method (one of others) in my demo with my fastest php framework in the world (i use similar bootstrap buttons to change the language in the page)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlusĀ®">
<meta name="Author" content="Custa">
<title>Document</title>
<style>
.flcn{ content:url(data:image/svg+xml;base64,PHN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AwIDAgMC04LjQgMjBsNy4zIDIyLjNINTBMMjguNCAyMDVsOC4zIDI1LjVMMTUgMjE0LjZsLTEzIDkuNUEyNTguNSAyNTguNSAwIDAgMCAwIDI1NmgyNTZWMGMtNTAuNiAwLTk3LjcgMTQuNy0xMzcuNCA0MHptOS45IDE5MC40bC0yMS43LTE1LjgtMjEuNyAxNS44IDguMy0yNS41TDcxLjcgMTg5aDI2LjhsOC4zLTI1LjUgOC4zIDI1LjVoMjYuOGwtMjEuNyAxNiA4LjMgMjUuNXptLTguMy0xMDBsOC4zIDI1LjQtMjEuNy0xNS43LTIxLjcgMTUuNyA4LjMtMjUuNS0yMS43LTE1LjdoMjYuOGw4LjMtMjUuNiA4LjMgMjUuNmgyNi44bC0yMS43IDE1Ljd6bTEwMC4xIDEwMGwtMjEuNy0xNS44LTIxLjcgMTUuOCA4LjMtMjUuNS0yMS43LTE1LjhoMjYuOGw4LjMtMjUuNSA4LjMgMjUuNWgyNi44TDIxMiAyMDVsOC4zIDI1LjV6bS04LjMtMTAwbDguMyAyNS40LTIxLjctMTUuNy0yMS43IDE1LjcgOC4zLTI1LjUtMjEuNy0xNS43aDI2LjhsOC4zLTI1LjYgOC4zIDI1LjZoMjYuOEwyMTIgMTMwLjN6bTAtNzQuN2w4LjMgMjUuNi0yMS43LTE1LjhMMTc3IDgxLjNsOC4zLTI1LjZMMTYzLjUgNDBoMjYuOGw4LjMtMjUuNUwyMDcgNDBoMjYuOEwyMTIgNTUuN3oiLz48L3N2Zz4=); }
/*
generated by me with php $flagencoded= base64_encode($svgimageloadedfrompath);
then with echo,fwrite,content output in some other way I generate
echo '.classname1{ content:url(data:image/svg+xml;base64,'.$flagencoded.');}';
so I got what you reading up
in my case all svg files are from github: flags public domain(free to anyone to use)
*/
p{
width: 30px;
height:30px;
}
</style>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
</head>
<body>
<div class="pb-3">
<div class="container">
<div class="row">
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="fles"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flfr"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flus"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flit"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flde"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flcn"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flro"></p>
</button>
</div>
<div class="col">
<button class="btn btn bg-info" type="submit">
<p class="flru"></p>
</button>
</div>
</div>
</div>
</div>
</body>
</html>
My media queries is not being applied to this one div .col-3 although it does work for others. Is that a problem with a selector/class?
#media screen and (min-width: 600px) and (max-width: 719px) {
.col-3 {
flex: 0 50%;
max-width: 50%;
}
}
<div class="row fade show">
<div class="col-3">
<div class="ProductBox_root__13DPQ">
<div class="ProductBox_photo__Xs8BM"><img
src="https://images.pexels.com/photos/245208/pexels-photo-245208.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260"
alt="Aenean Ru Bristique 1" class="ProductBox_image__1ECK5">
<div class="ProductBox_sale__1WcD7">sale</div>
<div class="ProductBox_buttons__uyJNx">Quick View<a href="#"
class="Button_small__2W39u"><svg aria-hidden="true" focusable="false" data-prefix="fas"
data-icon="shopping-basket" class="svg-inline--fa fa-shopping-basket fa-w-18 " role="img"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
<path fill="currentColor"
d="M576 216v16c0 13.255-10.745 24-24 24h-8l-26.113 182.788C514.509 462.435 494.257 480 470.37 480H105.63c-23.887 0-44.139-17.565-47.518-41.212L32 256h-8c-13.255 0-24-10.745-24-24v-16c0-13.255 10.745-24 24-24h67.341l106.78-146.821c10.395-14.292 30.407-17.453 44.701-7.058 14.293 10.395 17.453 30.408 7.058 44.701L170.477 192h235.046L326.12 82.821c-10.395-14.292-7.234-34.306 7.059-44.701 14.291-10.395 34.306-7.235 44.701 7.058L484.659 192H552c13.255 0 24 10.745 24 24zM312 392V280c0-13.255-10.745-24-24-24s-24 10.745-24 24v112c0 13.255 10.745 24 24 24s24-10.745 24-24zm112 0V280c0-13.255-10.745-24-24-24s-24 10.745-24 24v112c0 13.255 10.745 24 24 24s24-10.745 24-24zm-224 0V280c0-13.255-10.745-24-24-24s-24 10.745-24 24v112c0 13.255 10.745 24 24 24s24-10.745 24-24z">
</path>
</svg> ADD TO CART</a></div>
</div>
Let me confirm that I added
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
so it must be something else.
Hope this media query is placed at the bottom of your css file. If it isn't then the properties are being overridden. Kindly inspect and check if the element's properties are being overridden in the css tab
image is overflowing the container?
img{ width: 100% }
You could also target the div by Id
<div id="custom" class="col-3">
#custom.col-3 {
flex: 0 50%;
max-width: 50%;
border: 2px solid red
}
https://jsfiddle.net/brnt49je/
I decided to apply RWD by adding responsive classes to react component as follows:
className='col-12 col-sm-6 col-lg-3'>
This works for me, I hope someone will find this useful. Thank you for all your answers!
I have the following html:
<div class="text-center">
<img src="~/images/prof_grade_tech.svg" height="32" />
<span>Professional Grade Technology</span>
</div>
It comes out looking like this:
I would like to move the text span down by 2 pixels to better align it with the image. I've tried adding margin, padding, invisible border, but nothing seems to help. I've added vertical-align:bottom to the image and that kind of worked, but it moved the image too far down.
So how do I move the text 2 pixels down?
Consider these default factors:
<span> is an inline level element, top/bottom padding/margin will not apply.
vertical-align is set to baseline - aligns the baseline of the element.
To center align them vertically:
Option 1:
img, span {
display: inline-block;
vertical-align: middle;
}
span {
margin-bottom: -2px;
}
<div class="text-center">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M7.5 0h1v3h-1zm0 13h1v3h-1zM16 7.5v1h-3v-1zm-13 0v1H0v-1zM1.99 2.697l.707-.707 2.121 2.12-.707.708zm9.192 9.193l.707-.708 2.121 2.121-.707.707zm2.121-9.9l.707.707-2.12 2.121-.708-.707zM4.11 11.182l.708.707-2.121 2.121-.707-.707zM8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 1a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z'%3E%3C/path%3E%3C/svg%3E" width="32" height="32" />
<span>Professional Grade Technology</span>
</div>
Option 2:
img, span {
display: inline-block;
vertical-align: middle;
}
span {
position: relative;
bottom: -2px;
}
<div class="text-center">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M7.5 0h1v3h-1zm0 13h1v3h-1zM16 7.5v1h-3v-1zm-13 0v1H0v-1zM1.99 2.697l.707-.707 2.121 2.12-.707.708zm9.192 9.193l.707-.708 2.121 2.121-.707.707zm2.121-9.9l.707.707-2.12 2.121-.708-.707zM4.11 11.182l.708.707-2.121 2.121-.707-.707zM8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 1a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z'%3E%3C/path%3E%3C/svg%3E" width="32" height="32" />
<span>Professional Grade Technology</span>
</div>
Option 3:
img, span {
display: inline-block;
vertical-align: middle;
}
span {
transform: translateY(2px);
}
<div class="text-center">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M7.5 0h1v3h-1zm0 13h1v3h-1zM16 7.5v1h-3v-1zm-13 0v1H0v-1zM1.99 2.697l.707-.707 2.121 2.12-.707.708zm9.192 9.193l.707-.708 2.121 2.121-.707.707zm2.121-9.9l.707.707-2.12 2.121-.708-.707zM4.11 11.182l.708.707-2.121 2.121-.707-.707zM8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 1a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z'%3E%3C/path%3E%3C/svg%3E" width="32" height="32" />
<span>Professional Grade Technology</span>
</div>
Option 4:
div {
display: flex;
align-items: center;
}
span {
margin-left: 4px;
margin-bottom: -2px;
}
<div class="text-center">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M7.5 0h1v3h-1zm0 13h1v3h-1zM16 7.5v1h-3v-1zm-13 0v1H0v-1zM1.99 2.697l.707-.707 2.121 2.12-.707.708zm9.192 9.193l.707-.708 2.121 2.121-.707.707zm2.121-9.9l.707.707-2.12 2.121-.708-.707zM4.11 11.182l.708.707-2.121 2.121-.707-.707zM8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm0 1a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z'%3E%3C/path%3E%3C/svg%3E" width="32" height="32" />
<span>Professional Grade Technology</span>
</div>
Apply display: inline-block; and position: relative; to the image. Now you can move it in relation to its default position, for example by adding bottom: -2px
(I applied -6px in the snippet below to make it a bit more obvious)
As an alternative, you could apply similar settings to the span to move the text instead of the image.
img {
display: inline-block;
position: relative;
bottom: -6px;
}
<div class="text-center">
<img src="https://picsum.photos/id/1/40/20" height="32" width="auto" />
<span>Professional Grade Technology</span>
</div>
You can use different divs and with that use the margin or padding!
<div class="text-center">
<img src="~/images/prof_grade_tech.svg" height="32" />
<span>Professional Grade Technology</span>
</div>
<div id="span2" class="text-center">
<span>Professional Grade Technology</span>
</div>
<!-- CSS FILE --!>
#span2{
margin-top: 2px;
}
In my opinion, I suggest to append some div tags inside the logo.
By using 2 div tags within float: left, we make the 2 div is inline.
Combine display: table and display: table-cell to vertical center the height of divs.
.float-left {
float: left;
}
.d-table {
display: table;
height: 32px;
}
.d-table-cell {
display: table-cell;
}
.align-middle {
vertical-align: middle;
}
<div class="text-center">
<div class="float-left">
<div class="d-table">
<div class="d-table-cell align-middle">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/Firefox_Logo%2C_2017.svg/1024px-Firefox_Logo%2C_2017.svg.png" height="32" />
</div>
</div>
</div>
<div class="float-left">
<div class="d-table">
<div class="d-table-cell align-middle">
<span>Professional Grade Technology</span>
</div>
</div>
</div>
</div>