Stopping a div from splitting its contents when screen becomes too small? - css

I have the following html on a window, when the window becomes too small it splits the input and icon on a new line. I would like them to always be together. Any ideas ?
<div>
<input type="text" class="email-address"
value="long-long-long-user#test-test-test.com">
<i class="fa fa-clipboard fa-2x" aria-hidden="true"></i>
</div>
This is a the css
.email-address {
width: 300px;
}
Is there any way to ensure that they don't split up?
The div is simple place inside the body, and as you make the window smaller in width, (less than 300px) then the icon jumps to the line underneath.

By simply use width/max-width you can do like this
Fiddle demo
.email-address {
width: calc(100% - 40px); /* 40px, the icon width + padding */
max-width: 300px;
}
.email-address + i {
padding-left: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<input type="text" class="email-address" value="long-long-long-user#test-test-test.com">
<i class="fa fa-clipboard fa-1x" aria-hidden="true"></i>
</div>
Another option would be display: flex.
Fiddle demo
Stack snippet
div {
display: flex;
}
.email-address {
width: 300px;
min-width: 0;
}
.email-address + i {
padding-left: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<input type="text" class="email-address" value="long-long-long-user#test-test-test.com">
<i class="fa fa-clipboard fa-2x" aria-hidden="true"></i>
</div>

Try adding a class to the parent container:
<div class='parent'>
<input type="text" class="email-address" value="long-value">
<i class="fa fa-clipboard fa-2x" aria-hidden="true"></i>
</div>
Then add the following CSS:
.parent{
whitespace: nowrap;
}

Wrap your elements into a <span class="input-icon">
<div>
<span class="input-icon">
<input type="text" class="email-address" value="bla">
<i class="fa fa-clipboard fa-2x" aria-hidden="true"></i>
</span>
</div>
And than this CSS:
.input-icon{
white-space: nowrap;
}

Related

I use image and text side by side in footer but it creates problem when window is resized

Image after resize:
I use this code in my footer section. I have an image and some content side by side using media object class in bootstrap 4, but when the window is resized, the image and the content do not remain same and it creates a problem.
Here is my code:
<div class="col-lg-3 col-md-3 col-sm-6 mt-5">
<h5>Product</h5>
<div class="media">
<div class="media-left">
<a href="#"><img class="media-object"
src="./assets/Img/prod.png" alt="..."></a>
</div>
<div class="media-body">
<h6>vulputate velit consequat. </h6>
<div class="text-primary">
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
</div>
<span><s>Rs1200.00</s> Rs1000.00 </span>
</div>
</div>
</div>
Image I actually want:
Would you mind using only CSS instead of using Bootstrap? If no, then you may check out this answer. I have written the code in pure HTML and CSS:
.container {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: #2F2F2F;
font-family: Arial;
color: white;
}
.img1 {
width: 20%;
padding-left: 10px;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<title>Title of the page</title>
</head>
<body>
<div class="container">
<h2 style="padding: 10px;">Product</h2>
<img src="https://camo.githubusercontent.com/09e55b5e6a65a3ba9e38ed4de0f96ddd8ad46ba5c57b3e94d05222e0f127402a/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f323037383234352f3235393331332f35653833313336322d386362612d313165322d383435332d6536626439353663383961342e706e67"
class="img1">
<p>vulputate velit consequat</p>
<h3>⭐⭐⭐⭐⭐</h3>
<span><s>Rs 1200</s> Rs 1000</span>
</div>
</body>
</html>

Custom cursor on a element (behind?) a input

I use Bulma and I would like to be able to see the pointer cursor on the right icon in the input field.
.main {
max-width: 400px;
margin: auto;
padding-top: 10px;
}
.is-clickable {
cursor: pointer;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.0/css/bulma.min.css" rel="stylesheet"/>
<div class="main">
<div class="field">
<p class="control has-icons-left has-icons-right">
<input class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
<span class="icon is-small is-right is-clickable">
<i class="fas fa-check"></i>
</span>
</p>
</div>
</div>
What should I do to see the cursor?
Thanks
It ignores the cursor movement, because pointer-events: none has been added by Bulma. As you can see:
It needs to be pointer-events: auto; to see the cursor movement. You can find more information about pointer-events from MDN. Also, icon is not behind the input.
.main {
max-width: 400px;
margin: auto;
padding-top: 10px;
}
.is-clickable {
cursor: pointer;
pointer-events: auto !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.0/css/bulma.min.css" rel="stylesheet"/>
<div class="main">
<div class="field">
<p class="control has-icons-left has-icons-right">
<input class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
<span class="icon is-small is-right is-clickable">
<i class="fas fa-check"></i>
</span>
</p>
</div>
</div>

change resizer's properties thorguht css

i have a div which is resizeable through css.
HTML :
<div id="resize">
<img src="{{env.assets_url}}assets/images/minified_signhere.png" [hidden]="!isNameNull(sign.name)" [attr.id]="'sign-img' + myindex">
<img src="{{env.assets_url}}assets/images/minified_signhere_dim.png" [attr.id]="'dimimg' + myindex" [hidden]="isNameNull(sign.name)">
<div style="position: absolute;z-index: 1000;left: 100%;" class="signbtns">
<span style="font-size: 17px; margin-bottom: 5px" class="fa fa-trash float-right change-cursor" aria-hidden="true" (click)="deleteSign(myindex)"
data-toggle="tooltip" title="Click to delete the signature."></span>
<span style="font-size: 17px;" class="fa fa-pencil float-right change-cursor" (click)="editSign(myindex)" aria-hidden="true"
data-toggle="tooltip" title="Click to edit the signature."></span>
</div>
</div>
and following is CSS
#resize {
display: flex;
resize: both;
overflow:auto;
}
::-webkit-resizer {
background-color: red;
cursor: ew-resize;
}
div is being resize correctly. i want to customize the background color of resizer but the ::-webkit-resizer doesn't seem to work.
You change the color of #resize, not ::-webkit-resizer.

Why does the caret move when I try to limit the length of bootstrap button text?

Look at these two buttons, styled with Bootstrap:
body { margin: 10px !important; }
button.limited-text-length span.text {
width: 50px;
display: inline-block;
overflow-x: hidden;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<button class="btn" type="button">
<span class="text">Dropdown</span>
<span class="caret"></span>
</button>
<button class="btn limited-text-length" type="button">
<span class="text">Dropdown</span>
<span class="caret"></span>
</button>
In the second one I tried to forcibly limit the length of the label by setting width, display: inline-block and overflow-x: hidden. However, as you can see, this causes the dropdown triangle to move downwards. Why is that and how can I do it properly?
You converted your span into inline-block.
Adding vertical-align:middle will position the inline-block item in the middle of the line.
body { margin: 10px !important; }
button.limited-text-length span.text {
width: 50px;
display: inline-block;
vertical-align: middle;
overflow-x: hidden;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<button class="btn" type="button">
<span class="text">Dropdown</span>
<span class="caret"></span>
</button>
<button class="btn limited-text-length" type="button">
<span class="text">Dropdown</span>
<span class="caret"></span>
</button>

center div with Font Awesome

I have a site I am making with Bootstrap 3.3.5. I would like to center the div with the icons and I also want the icons centered, like what text-align: center; would do if it was just text and not the Fonat Awesome icons. This is what I have tried so far, the css is in my css folder and in the custom.css page.
#media (min-width: 992px) {
.col-md-1-5 { width: 20%; }
.col-md-2-5 { width: 40%; }
.col-md-3-5 { width: 60%; }
.col-md-4-5 { width: 80%; }
.col-md-5-5 { width: 100%; }
}
#media (min-width: 1200px) {
.col-lg-1-5 { width: 20%; }
.col-lg-2-5 { width: 40%; }
.col-lg-3-5 { width: 60%; }
.col-lg-4-5 { width: 80%; }
.col-lg-5-5 { width: 100%; }
}
.show-grid [class^=col-] span,
.container-fluid .show-grid [class^=col-] {
display: block;
padding-top: 1rem;
padding-bottom: 1rem;
text-align: center;
}
[class^=col-] {
margin-bottom: 2rem;
}
<div class="row show-grid">
<div class="col-sm-6 col-md-4-5 col-lg-1-5 text-center"><span class=""><a href="https://play.google.com/store/apps/details?id=com.nationalkitchencabinets.kitchensolutions" target="_blank">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-google fa-stack-1x fa-inverse"></i>
</span>
</a></span>
</div>
<div class="col-sm-6 col-md-5-5 col-lg-1-5 text-center"><span class=""><a href="https://appsto.re/us/IxCMbb.i" target="_blank">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-android fa-stack-1x fa-inverse"></i>
</span>
</a></span>
</div>
<div class="col-sm-6 col-md-3-5 col-lg-1-5 text-center"><span class=""><a href="mailto:info#nationalkitchencabinets.com">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-envelope fa-stack-1x fa-inverse"></i>
</span>
</a></span>
</div>
<div class="col-sm-6 col-md-3-5 col-lg-1-5 text-center"><span class=""><a href="https://www.facebook.com/NationalKitchenCabinets/" target="_blank">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a></span>
</div>
<div class="col-sm-6 col-md-3-5 col-lg-1-5 text-center"><span class=""><a href="tel:1-413-374-2939">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-phone fa-stack-1x fa-inverse"></i>
</span>
</a></span>
</div>
</div>
This is what it looks like now, the icons are left aligned,
The elements that you are trying to align are block elements, so you simply need to use margin: 0 auto rather than text-align: center.
.show-grid [class^=col-] span,
.container-fluid .show-grid [class^=col-] {
text-align: center;
}
Should be:
.show-grid [class^=col-] span,
.container-fluid .show-grid [class^=col-] {
margin: 0 auto;
}
I've created a Bootply showcasing this here.
UPDATE:
A temporary hack to have the icons display next to each other on mobile would be something like the following:
#media (max-width: 500px) {
.col-sm-6 {
width: 20% !important;
float: left;
}
}
However, this is a workaround, and you should really simply set a smaller column width. Bootstrap columns always add up to 12, and col-sm-6 refers to '6 columns on small devices'. Typically, you'd use something like col-sm-2 col-md-12 col-lg-12 to represent that each element should take up the full width on medium and large devices, and only take up one-sixth of the width on small devices. Of course, 12 isn't divisible by 5, so you'd have to come up with your own workaround, such as centralisation or padding ;)
A secondary fiddle showcasing the hack is available here.
Hope this helps!

Resources