Increase HTML Button Font size without altering button size - html

The issue I am having is that when I change the size of the font in my button, the button then resizes. As of now, I would like to keep the buttons at one specific size. So, I have fixed my buttons to a specific size but now I cannot change the font size. I am currently running my program on Chrome.
Here is the HTML chunk:
<div class="file-input-wrapper">
<button class="btn-file-input">Upload Documents</button>
<input type="file" name="filesToUpload[]" id="filesToUpload" multiple="" onChange="makeFileList();" />
</div>
<p>
<strong>Files You Selected:</strong>
<ul id="fileList">
<li>No Files Selected</li>
</ul>
<div class="file-input-wrapper1">
<button class="btn-file-input1">Upload Documents</button>
<input type="submit" value="Upload!" />
</div>
</p>
<style type="text/css">
.file-input-wrapper {
width: 400px;
height: 125px;
overflow: hidden;
position: relative;
}
.file-input-wrapper>input[type="file"] {
font-size: 200px;
position: absolute;
top: 0;
right: 0;
opacity: 0;
}
.file-input-wrapper>.btn-file-input {
display: inline-block;
width: 400px;
height: 125px;
}
.file-input-wrapper:hover>.btn-file-input {
background-color: #aaa;
}
.file-input-wrapper1 {
width: 400px;
height: 125px;
overflow: hidden;
position: relative;
}
.file-input-wrapper1>input[type="submit"] {
font-size: 200px;
position: absolute;
top: 0;
right: 0;
opacity: 0;
}
.file-input-wrapper1>.btn-file-input1 {
display: inline-block;
width: 400px;
height: 125px;
}
.file-input-wrapper1:hover>.btn-file-input1 {
background-color: #ffff00;
}
</style>

You can set the button font size with the following:
button {
font-size: 40px;
}
Since your buttons have a defined height and width, it should not change their dimensions.

Add an additional class to all your buttons. Even if you have some "buttons" that are not actually buttons, but instead input type="submit" or input type="button", add this class to all of those things.
Then do this in your CSS:
.some_class_added_to_all_buttons{
width: some-width;
height: some-height;
font-size: some-font-size;
}
if you have a button that already has a class, add an additional one like this
<button class="btn-file-input1 additional_class">Upload Documents</button>

Related

Extending image tag over an existing tag by overlapping

I am trying to extend the image to the top, passed the previous HTML tag. This is what I have so far:
.toggle-modal {
display: block;
cursor: pointer;
padding: 8px 30px;
position: relative;
margin: 0 auto;
top: 10px;
left: 80px;
}
#image {
width: 200px;
height: 180px;
}
<div className='card'>
<FaRegStar size={20} className='toggle-modal' onClick={openModal}/>
<Modal toggle={modalState} action={openModal} />
<div onClick={refreshOverview}>
{product.image ? (<img src={product.image[0].url} alt={product.name} id='image'/>) :
'image not available'
}
</div>
</div>
rendered top image card

CSS show a bigger image while hover

Ive got a product page with a smaller image of the product.
Now I want to show a bigger version of this image with a colored background covering the whole page, while I hover the smaller image.
The problem is, that the bigger image flickers while I move the mouse around.
My CSS:
#zoomed-product-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(162, 130, 192, 0.8);
z-index: 0;
visibility: hidden;
}
#zoomed-product-img img {
display: block;
margin: auto auto;
}
.productsdetail-image:hover~#zoomed-product-img {
visibility: visible;
}
My HTML:
<div class="productdetails">
<div class="productsdetail-image">
<img src="/assets/images/products/{{page.name}}.png" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
<div id="zoomed-product-img">
<img src="/assets/images/products/{{page.name}}.png" alt="Produktbild">
</div>
Can you help me? Maybe my way of thinking is wrong.
I think it flickers because when I show the bigger image, it is above (z index) the small one and I am not hovering the image anymore so it disappears.
I would also love to solve this with javascript, if you can give me any advice.
You need to specify dimensions for the container of the image. This is why it is flickering. I also used display: none; and display:block to hide and show the images.
.productdetails {
position: relative;
}
#zoomed-product-img {
display: none;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
}
/* This is the product detail image styles */
.productsdetail-image {
display: block;
height: 200px;
width: 200px;
}
.productsdetail-image:hover img {
display: none;
}
.productsdetail-image:hover + #zoomed-product-img {
display: block;
}
HTML
<div class="productdetails">
<div class="productsdetail-image">
<img src="https://placeimg.com/200/200/animals" alt="Produktbild">
</div>
<div id="zoomed-product-img">
<img src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
Demo:
http://jsfiddle.net/n07bt46y/
Please check this in full page
$(document).ready(function(){
$('.productsdetail-image img').hover(function() {
$(this).hide();
$('#zoomed-product-img ').show(500);
});
$('#zoomed-product-img .close').click(function(){
$(this).parent().hide();
$('.productsdetail-image img ').show();
});
});
.productsdetail-image img {
width: 150px;
height: auto;
transition: all 0.5s ease;
}
#zoomed-product-img {
display: none;
position: absolute;
width: 100%;
height: 100%;
background-color: red;
}
#zoomed-product-img span.close {
position: absolute;
color: #fff;
cursor: pointer;
top: 20px;
right: 20px;
}
#zoomed-product-img img {
position: absolute;
width: 300px;
height: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: aUto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="productdetails">
<div class="productsdetail-image">
<img src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div id="zoomed-product-img">
<span class="close">close</span>
<img class="zoom-img" src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
Are you wanna build something like that? Hoppefully that fiddle can help you

How to make "fit-content" take take full width? (CSS)

I'm designing a hybrid mobile app and I have a simple form that has a clickable icon inside it. For the icon to stay always in the same place, regardless of screen sizes, someone suggested I added the property width: fit-content. This makes the icon stay where it's supposed to stay. However, now my form doesn't take 100% width anymore. If I change width: fit-content to width: 100%, then the icon loses it's spot.
This is what I need it to look like:
And I manage this width width: 100%
This is what it's looking like now:
And this is what it looks like with width: fit-content
Here's my code:
.wallet-body {
width: fit-content;
margin: 0 auto;
float: left;
}
.form-group {
position: relative;
}
.form-group input,
.pin-input {
border: 1px solid #2C2C2C;
height: 48px;
}
.qr-scanner-img {
width: 11%;
position: absolute;
top: 50%;
right: 2%;
transform: translateY(-50%);
}
<div class="wallet-body">
<form class="form-pagar">
<div class="form-group">
<input type="amount" class="form-control" id="amount" placeholder="Monto">
</div>
<div class="form-group">
<input type="IDuser" class="form-control" id="IDuser" placeholder="Email del destinatario">
<a href="#">
<img class="qr-scanner-img" src="img/qr.svg" alt="qr"></a>
</a>
</div>
<button type="button" class="btn btn-block btn-confirmar" data-toggle="modal" data-target="#modalConfirmation">Confirmar</button>
</form>
</div>
If I understood correctly you can use the position absolute for the icon.
you should add width:100% for .wallet-body and .pin-input
`
.wallet-body {
width: 100%;
margin: 0 auto;
float: left;
}
.form-group input,
.pin-input {
border: 1px solid #2C2C2C;
height: 48px;
width: 100%;
}
`
HTML :: Remove class from image and add in a tag
<a href="#" class="qr-scanner-img">
<img class="" src="img/qr.svg" alt="qr"></a>
CSS::
.qr-scanner-img {
width: 11%;
position: absolute;
top: 50%;
right: 2%;
transform: translateY(-50%);
text-align: right;
}
Hope will work.

Having a <button> tag completely over a <div> element

I have tried to make a tag that completely covers a div element and when clicked, the button element would disappear.
HTML:
I have tried setting height and width to 100%, but this does not fill the area entirely... how do I fix this?
#startstorybutton {
height: 100%;
width: 100%;
position: absolute;
top: 7.5vw;
right: 20vw;
z-index: 10;
background-color: #f4511e;
color: white;
Font-size: 50px;
font-style: italic;
transition: all 0.6s;
cursor: url(cursors/select.PNG), pointer;
}
#story {
background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Three_little_pigs_%28geograph_4633727%29.jpg/1200px-Three_little_pigs_%28geograph_4633727%29.jpg");
background-size: 100%;
height: 40%;
width: 80%;
margin: 0 auto;
}
<div id="story">
<div>
<p id="storytitle">The Three Little Pigs</p>
<div>
<p id="storybox"></p>
</div>
<div id="storybuttonsection">
<button type="button" id="backbutton"><span>Go back</span></button>
<p id="pagenumber">121212</p><button id="continuebutton"><span>Continue</span></button>
</div>
</div>
<button type="button" id="startstorybutton">Start the story!</button>
</div>
You have to position the button element on top of the "hidden element", if you set the main element position to relative you can then position the child element absolute over it (top: 0; right: 0) with the height and width to 100%.
For hide the button, the easy way is to add a listener event to the button and then hide it (or remove it) with javascript.
#startstorybutton {
height: 100%;
width: 100%;
position: absolute;
top: 0;
right: 0;
z-index: 10;
background-color: #f4511e;
color: white;
Font-size: 50px;
font-style: italic;
transition: all 0.6s;
cursor: url(cursors/select.PNG), pointer;
}
#story {
background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Three_little_pigs_%28geograph_4633727%29.jpg/1200px-Three_little_pigs_%28geograph_4633727%29.jpg");
background-size: 100%;
height: 40%;
width: 80%;
margin: 0 auto;
position: relative;
}
<div id="story">
<div>
<p id="storytitle">The Three Little Pigs</p>
<div>
<p id="storybox"></p>
</div>
<div id="storybuttonsection">
<button type="button" id="backbutton"><span>Go back</span></button>
<p id="pagenumber">121212</p><button id="continuebutton"><span>Continue</span></button>
</div>
</div>
<button type="button" id="startstorybutton" onclick="this.style.display = 'none'">Start the story!</button>
</div>
I am not very sure of your HTML structure. But as you described your problem I have created an example for you.
You need t make changes in your HTML to make it simple and straightforward.
The story div contains the button, which will be absolutely positioned to fit the entire div.
I have thrown in a small bit of jQuery to show how it will look like.
$(function(){
$("button.overlay").click(function(){
$(this).hide();
});
});
.story{
width: 250px;
height: 100px;
border: 1px solid black;
text-align:center;
position: relative;
}
.overlay{
position: absolute;
top:0px;
left:0px;
height: 100%;
width:100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="story">
Here goes the story!
<button class="overlay">read story button</button>
</div>

Customized <input type=“file”>?

I need to add in my form a few customized <input type=“file”>
I tried to use this code
<div id="upload-file-container">
<input type="file" name="pic[]" class="photo" value="Add photo" />
</div>
CSS
#upload-file-container {
position: relative;
width: 50px;
height: 20px;
overflow: hidden;
}
#upload-file-container input {
position: absolute;
left: 0;
top: 0;
font-size: 20px;
opacity: 0;
margin: 0;
padding: 0;
border: none;
width: 50px;
height: 20px;
}
but my inputs just became invisible.
http://jsfiddle.net/FXTCg/4/
How to make visible input title "Add photo"?
take a look at this: http://jsfiddle.net/gabrieleromanato/mxq9R/ . Your input need to be invisible opacity: 0 becuase you cannot apply any style or custom text in it. You need to put your visible content underneath it