Here's a fiddle with my HTMl and CSS:
https://jsfiddle.net/e06btr2w/2/
This is a sample of a simple UI for categorising images. The user should be shown an overview of the image (i.e. the entire image) but be able to zoom in and pan for closer inspection if necessary.
I would like to allow the user to pan and pinch zoom the image only, without affecting the other UI elements.
Is this possible with CSS only? I'm not a day to day web dev any more, but I see there's a touch-action CSS rule now which I thought would do what I want, but it doesn't seem to:
touch-action: pinch-zoom pan-x pan-y;
Maybe I'm using it wrong? I know this is possible with some JS but thought it would be much simpler if it could be CSS only.
HTML:
<div class="target fill">
<img class="classification" src="https://c4.wallpaperflare.com/wallpaper/528/806/409/1920x1080-beach-desktop-background-wallpaper-preview.jpg" />
</div>
<div class="destinations">
<form method="post" action="/SortClassifications/">
<input type="hidden" name="target" value="ForRemoval" />
<input type="hidden" name="filename" value="2022-01-17-223050.png" />
<input name="destination" type="submit" class="btn btn-danger" value="Remove" />
</form>
<form method="post" action="/SortClassifications/">
<input type="hidden" name="target" value="Attack" />
<input type="hidden" name="filename" value="2022-01-17-223050.png" />
<input name="destination" type="submit" class="btn btn-primary" value="Attack" />
</form>
<form method="post" action="/SortClassifications/">
<input type="hidden" name="target" value="Back" />
<input type="hidden" name="filename" value="2022-01-17-223050.png" />
<input name="destination" type="submit" class="btn btn-primary" value="Back" />
</form>
<form class="undo" style="float: right;" method="post" action="/SortClassifications/Home/Undo?undoFile=2022-01-17-223039.png&undoTarget=Claim">
<input name="destination" type="submit" class="btn btn-warning" value="Undo" />
</form>
</div>
CSS
body {
background-color: black;
position: relative;
}
.container {
height: 100%;
width: 100%;
}
.classification {
width: 100%;
top: 50%;
margin-bottom: 20px;
}
div.destinations {
position: fixed;
bottom: 0px;
left: 0px;
max-width: 80%;
}
.destinations form {
float: left;
margin: 0 20px 10px 0;
}
.destinations .undo {
margin-right: 20px;
position: fixed;
right: 0px;
}
.fill {
display: flex;
justify-content: center;
align-items: center;
overflow: hidden
}
.fill img {
flex-shrink: 0;
min-width: 100%;
min-height: 100%
}
.target {
width: 100%;
height: 100%;
touch-action: pinch-zoom pan-x pan-y;
}
html {
position: relative;
min-height: 100%;
}
Related
I am trying to create a flashcard system where users will see input on the left and right for the front and back of their cards.
I am trying to have the Label above, submit button below and the front and back inputs beside each other.
My attempts have results in all 4 being stacked ontop or beside each other. Is this something possible with html and css?
HTML
<div class="view_new_flashcard">
<form method="POST" action="'.newcard($conn).'">
<input type="hidden" name="PostID" value="'.$PostID.'">
<input type="hidden" name="MatchUserID" value="'.$UserID.'">
<label>Enter New Card Information</label>
<br><br>
<input type="text" name="FrontSide" placeholder="Front of Card">
<input type="text" name="BackSide" placeholder="Back of Card">
<br>
<br>
<button type="submit" name="addcard">Add New Card</button>
</form>
CSS
.view_new_flashcard {
display: flex;
justify-content: space-evenly;
box-sizing: border-box;
width: 100%;
padding: 5px;
}
.view_new_flashcard form {
width: 100%;
height: auto;
}
.view_new_flashcard input {
display: inline-block;
box-sizing: border-box;
border: 1px solid #eeeeee;
border-radius: 8px;
/* width: 100%; */
height: auto;
}
<div class="view_new_flashcard">
<form method="POST" action="'.newcard($conn).'">
<input type="hidden" name="PostID" value="'.$PostID.'">
<input type="hidden" name="MatchUserID" value="'.$UserID.'">
<label>Enter New Card Information</label>
<br><br>
<input type="text" name="FrontSide" placeholder="Front of Card">
<input type="text" name="BackSide" placeholder="Back of Card">
<br>
<br>
<button type="submit" name="addcard">Add New Card</button>
</form>
</div>
You could put the inputs in adiv with display: flex and use flex-grow: 1 on the input.
.view_new_flashcard {
display: flex;
justify-content: space-evenly;
box-sizing: border-box;
width: 100%;
padding: 5px;
}
.view_new_flashcard form {
width: 100%;
height: auto;
background: grey;
}
.view_new_flashcard input {
display: inline-block;
box-sizing: border-box;
border: 1px solid #eeeeee;
border-radius: 8px;
/* width: 100%; */
height: auto;
flex-grow: 1;
margin: 0 3px;
}
.view_new_flashcard .input-container {
display: flex;
}
<div class="view_new_flashcard">
<form method="POST" action="'.newcard($conn).'">
<input type="hidden" name="PostID" value="'.$PostID.'">
<input type="hidden" name="MatchUserID" value="'.$UserID.'">
<label>Enter New Card Information</label>
<br><br>
<div class="input-container">
<input type="text" name="FrontSide" placeholder="Front of Card">
<input type="text" name="BackSide" placeholder="Back of Card">
</div>
<br>
<br>
<button type="submit" name="addcard">Add New Card</button>
</form>
</div>
I just wonder is here is any easy way to make search button like this:There is a search form I want to make
For now I have smth like this:This is what I have for now
And there is HTML and CSS:
.path1{
max-width: 18px;
max-height: 18px;
}
.search-button{
border-bottom: #0A093D;
width: 30%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
}
<div class="search-button">
<form id="form">
<button><img class="path1" src="C:\Users\przem\Projekty\strona-task\img\1024px-Search_Icon.svg.png"></img></button>
<input type="search" id="query" name="q" placeholder="Search...">
</form>
</div>
you can also put a unicode inside the placeholder.
.path1{
max-width: 18px;
max-height: 18px;
}
.search-button{
border-bottom: #0A093D;
width: 30%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
}
<div class="search-button">
<form id="form">
<input type="search" id="query" name="q" placeholder=" 🔍︎ Search...">
</form>
</div>
Here you go...
input {
border: none;
}
.search-button {
width: 250px;
border-bottom: 2px solid lightgrey;
padding-bottom: 10px;
}
<div class="search-button">
<form id="form">
<button><img class="path1" src="C:\Users\przem\Projekty\strona-task\img\1024px-Search_Icon.svg.png"></button>
<input type="search" id="query" name="q" placeholder="Search...">
</form>
</div>
This question already has answers here:
Flexbox: center horizontally and vertically
(14 answers)
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Closed 2 years ago.
I have a position:fixed container (div#popup)
#popup {
height: 60vh;
width: 60vw;
/* visibility: hidden; */
position: fixed;
left: 20vw;
top: 20vh;
border-radius: 8%;
background-color: rgb(241, 237, 231);
}
#popup form {
position: static;
margin: auto;
}
<div id='popup'>
<form action='emailform.php' method="POST">
<input type="text" name='name' placeholder="Name: "/>
<input type="text" name='mail' placeholder="Your Email: "/>
<input type="text" name='subject' placeholder="Subject: "/>
<textarea name='message' placeholder="Message: "></textarea>
<button type='submit' name="submit">Submit</button>
</form>
</div>
that contains a form that isnt fixed. Right now the form is just sticking to the top of the container. How do I center it? I've tried margin: auto and it doesn't work.
I'm guessing this should be a simple fix, but can't think of it.
Thanks!
You can make the container display :flex, flex-direction:column and use justify-content: center;
#popup {
height: 60vh;
width: 60vw;
/* visibility: hidden; */
position: fixed;
left: 20vw;
top: 20vh;
border-radius: 8%;
background-color: rgb(241, 237, 231);
display :flex;
flex-direction:column;
justify-content: center;
}
#popup form {
position: static;
margin: auto;
}
<div id='popup'>
<form action='emailform.php' method="POST">
<input type="text" name='name' placeholder="Name: "/>
<input type="text" name='mail' placeholder="Your Email: "/>
<input type="text" name='subject' placeholder="Subject: "/>
<textarea name='message' placeholder="Message: "></textarea>
<button type='submit' name="submit">Submit</button>
</form>
</div>
If you want horizontally center too you can do the same to the form but use row direction on the container:
#popup {
height: 60vh;
width: 60vw;
/* visibility: hidden; */
position: fixed;
left: 20vw;
top: 20vh;
border-radius: 8%;
background-color: rgb(241, 237, 231);
display :flex;
flex-direction:row;
justify-content: center;
}
#popup form {
position: static;
margin: auto;
display :flex;
flex-direction:column;
justify-content: center;
}
<div id='popup'>
<form action='emailform.php' method="POST">
<input type="text" name='name' placeholder="Name: "/>
<input type="text" name='mail' placeholder="Your Email: "/>
<input type="text" name='subject' placeholder="Subject: "/>
<textarea name='message' placeholder="Message: "></textarea>
<button type='submit' name="submit">Submit</button>
</form>
<form action='emailform.php' method="POST">
<input type="text" name='name' placeholder="Name: "/>
<input type="text" name='mail' placeholder="Your Email: "/>
<input type="text" name='subject' placeholder="Subject: "/>
<textarea name='message' placeholder="Message: "></textarea>
<button type='submit' name="submit">Submit</button>
</form>
</div>
I want to position my button on the right side using CSS.
here's the script:
<input id="search" class="form-control" type="text" placeholder="Search Location" style="margin-left: 100px; margin-top: 10px; width: 30%; z-index: 1;">
<input type="button" class="btn btn-default" onclick="location.reload();" style="width: 10%; margin-top: 10px; position: absolute; z-index: 1; background-color: #ffffff; border: 1px solid #dce4ec; color: #2c3e50" value="Refresh" />
<div id="map" style="position: relative;"></div>
Try this
.search-form input {
display: inline-block;
}
<div class="search-form">
<input id="search" class="form-control" type="text" placeholder="Search Location" style="margin-left: 100px; margin-top: 10px; width: 30%; z-index: 1;">
<input type="button" class="btn btn-default" onclick="location.reload();" style="width: 10%; margin-top: 10px; position: absolute; z-index: 1; background-color: #ffffff; border: 1px solid #dce4ec; color: #2c3e50" value="Refresh" />
</div>
<div id="map" style="position: relative;"></div>
Add all into one container and position the container, then add width to both to be equal 100%:
<style>
.container {
position: absolute;
top: 10px;
left: 100px;
}
.container #search {
width:80%;
}
.container .btn {
width:20%;
}
</style>
<div class="container">
<input id="search" class="form-control" type="text" placeholder="Search Location">
<input type="button" class="btn btn-default" onclick="location.reload();" value="Refresh" />
</div>
or, if you use bootstrap3, just follow this link:
http://getbootstrap.com/css/#forms-inline
.main{
width:300px;
height:25px;
position:relative;
}
.button{
position:absolute;
right:-75px;
top:0px;
}
<form>
<div class="main">
<input type="text" style="width:100%;" placeholder="Search Here"/>
<button type="reset" class="button">Refresh</button>
</div>
</form>
Try It Once
I'm trying to change the div #header-search when focus the input #search. so when people focus the search field get bigger!
<div id="header-search">
<form >
<div class="input-box">
<input id="search" type="search" name="q" value="" class="input-text required-entry" maxlength="128" placeholder="Search" autocomplete="off">
<button type="submit" title="Search" class="button search-button"></button>
</div>
<div id="search_autocomplete" class="search-autocomplete" style="display: none;"></div>
</form>
</div>
Style:
#header-search{
display: block;
position: absolute;
top: 0px;
left: 200px;
width: 40%;
height: 80px;}
#search{
width: 100%;
height: 80px;
}
#search:focus #header-search{
left: 0px;
width: 100%;
}