I followed a guide on the internet to implement a search bar on top of my navigation bar and responsive, but i have a problem when viewing with mobile, my search box button is at below of my search box.
something like this.
here is my code in HTML
<div class="search-container">
<form action="/">
<input type="text" placeholder="seach..." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
and my css
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
}
.topnav .search-container button:hover {
background: #ccc;
}
#media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav a, .topnav span, .topnav input[type=text], .topnav .search-container button {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}
How can I make the button in mobile view to be at the same row beside at right of my search box?
display: block; makes both input and button "put newline after", also they both are width: 100%; which is bad for both elements, if you make them inline-block (they already are by default) and set width that both fits, they be next to each other.
For example like this:
body, html { /* just example */
margin: 0;
padding: 0;
background-color: grey;
}
.topnav:after { /* clearfix so the .topnav container keeps its size properly */
content: "";
clear: both;
display: table;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
/* no need for float: right; here, you can comment-out the whitespace in html */
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
text-align: center;
/* non-flex version require harcoded width (unless you correct it with javascript) */
width: 40px;
}
.topnav .search-container button:hover {
background: #ccc;
}
#media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav .search-container input[type=text] {
border: 1px solid #ccc;
padding: 14px;
/* padding (left+right), border (left+right), button width */
width: calc(100% - 28px - 2px - 40px);
/* bit easier like that: */
/*
box-sizing: border-box;
width: calc(100% - 40px);
*/
}
.topnav .search-container button {
margin-right: 0;
/* correcting height difference between input[type=text] with border and button without border */
padding: 15px 14px;
}
}
<div class="topnav">
<div class="search-container">
<form action="/">
<input type="text" placeholder="seach..." name="search"><!--
--><button type="submit"><i class="fa fa-search">...</i></button>
</form>
</div>
</div>
There is major disadvantage with that aproach and that is the need of hardcoded width of button.
Another way is to use position: absolute;, old fashion but simple, for example like this:
// little demonstation of variable width
var times = 4;
setInterval(function(){
document.querySelector('button>i').innerText = '.'.repeat(times++);
if(times>6){ times = 3; }
}, 1000);
body, html { /* just example */
margin: 0;
padding: 0;
background-color: grey;
}
.topnav:after { /* clearfix so the .topnav container keeps its size properly */
content: "";
clear: both;
display: table;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
/* no need for float: right; here, you can comment-out the whitespace in html */
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
text-align: center;
}
.topnav .search-container button:hover {
background: #ccc;
}
#media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav .search-container input[type=text] {
border: 1px solid #ccc;
padding: 14px;
box-sizing: border-box;
width: 100%;
}
.topnav .search-container button {
position: absolute;
top: 0;
right: 0;
margin-right: 0;
/* correcting height difference between input[type=text] with border and button without border */
padding: 15px 14px;
}
}
<div class="topnav">
<div class="search-container">
<form action="/">
<input type="text" placeholder="seach..." name="search"><!--
--><button type="submit"><i class="fa fa-search">...</i></button>
</form>
</div>
</div>
Or you can use flex-box, which is modern and more flexible, for example like this:
// little demonstation of variable width
var times = 4;
setInterval(function(){
document.querySelector('button>i').innerText = '.'.repeat(times++);
if(times>6){ times = 3; }
}, 1000);
body, html { /* just example */
margin: 0; padding: 0;
background-color: grey;
}
.topnav:after { /* clearfix so the .topnav container keeps its size properly */
content: "";
clear: both;
display: table;
}
.topnav .search-container {
float: right;
}
/* following two blocks are most imporant */
.topnav .search-container form {
display: flex;
flex-wrap: nowrap;
align-items: stretch;
}
.topnav .search-container input[type=text] {
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
/* no need for float: right; here, you can comment-out the whitespace in html */
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
text-align: center;
/* no need for hardcoded width */
}
.topnav .search-container button:hover {
background: #ccc;
}
#media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav .search-container input[type=text] {
border: 1px solid #ccc;
padding: 14px;
}
.topnav .search-container button {
margin-right: 0;
padding: 14px; /* height is automatically corrected by flex */
}
}
<div class="topnav">
<div class="search-container">
<form action="/">
<input type="text" placeholder="seach..." name="search"><!--
--><button type="submit"><i class="fa fa-search">...</i></button>
</form>
</div>
</div>
Related
I am trying to use the following header menu template across my website. unfortunately, the menu hides the top part of my page content. I am a newbie. Please help. I tried, removing z-index, adding bottom margin, noting works.
The header.php code
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Responsive Hamburger Menu</title>
</head>
<body>
<!-- partial:index.partial.html -->
<header class="header">
<a href="" class="logo">
<img src="https://placeholder.com/wp-content/uploads/2018/10/placeholder.com-logo1.jpg"
class="logoimage"/></a>
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn">
<span class="navicon"></span>
</label>
<ul class="menu">
<li class="contactme">Contact Me</li>
<li class="aboutme">About Me</li>
<li class="projects">Projects</li>
<li class="Home">Home</li>
</ul>
</header>
<!-- partial -->
<style>
body {
margin: 0;
font-family: Helvetica, sans-serif;
background-color: #fffceb;
}
a {
color: #000;
}
/* header */
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgba(0,0,0,.1);
position: fixed;
width: 100%;
z-index: 3;
}
.header ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.header li a {
display: block;
padding: 20px 20px;
text-decoration: none;
}
.header li a:hover,
.header .menu-btn:hover {
background: rgb(255, 245, 246);
color: rgb(247, 133, 152);
}
.header .logo {
display: block;
float: left;
font-size: 2em;
padding: 10px 20px;
text-decoration: none;
}
/* menu */
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
/* menu icon */
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
/* menu btn */
.header .menu-btn {
display: none;
}
.header .menu-btn:checked ~ .menu {
max-height: 240px;
}
.header .menu-btn:checked ~ .menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked ~ .menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked ~ .menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
top: 0;
}
.logoimage{
width: 130px;
}
/* 48em = 768px */
#media (min-width: 48em) {
.header li {
float: left;
}
.header li a {
padding: 20px 30px;
}
.header .menu {
clear: none;
float: right;
max-height: none;
}
.header .menu-icon {
display: none;
}
.Home{
order: 1;
}
.projects{
order: 2;
}
.aboutme{
order: 3;
}
.contactme{
order: 4;
}
}
#media only screen and (max-width: 600px) {
.menu{
display: flex;
flex-direction: column-reverse;
}
}
</style>
</body>
</html>
Then I have a index.php where I include this header.
The style related to my index.php is
body {
background-color: #f2f2f2;
}
.formular input:disabled {
background-color: #dddddd;
}
.hint {
color: grey;
}
.title {
font-weight: bold;
}
p.subtitle {
font-weight: bold;
}
.requiredSymbol {
color: red;
}
.formular input[readonly="readonly"] {
background-color: #dddddd;
}
form.formular,
.validationEngineContainer {
/*background-color: #FFFFFF;*/
font-family: tahoma, verdana, "sans-serif";
font-size: 12px;
padding: 20px;
border: 1px solid #a5a8b8;
width: 700px;
margin: 0 auto;
}
.formular fieldset {
margin-top: 20px;
padding: 15px;
border: 1px solid #b5b8c8;
border-radius: 5px;
}
Your header css should have a position:relative. And you can add some margin to add distance from whatever is in the body.
Example shown below:
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgb(0 0 0 / 10%);
position: relative;
width: 100%;
z-index: 3;
margin-bottom: 10px;
}
The button and text fields on my login page are unresponsive / I am unable to click or interact with them. It worked fine yesterday and is linked to a PHP database. I have no idea what code I changed but it was possibly CSS that has stopped it working. Any advice would be great as I am lost.
I have tried editing CSS but to avail.
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Maoine in Eirinn (MIE) Wild Atlantic Gaeltacht Properties</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<div id="container">
<?php include("includes/header.html");?>
<?php include("includes/nav.html");?>
<div id="content">
<?php
if (empty($_SESSION))
session_start();
if (isset($_SESSION['errors'])) {
echo "<div class='form-errors'>";
foreach($_SESSION['errors'] as $error)
{
echo "<p>";
echo $error;
echo "</p>";
}
echo "</div>";
}
unset($_SESSION['errors']);
?>
<div id="login">
<h3> Login </h3>
<form action="login_action.php" method="POST">
<p>
Username: <input type="text" name="adminname" required="required">
</p><p>
Password: <input type="password" name="password" required="required">
</p><p>
<input type="submit" value="Login">
</p>
</form>
</div>
</div>
<?php include("includes/footer.html");?>
</div>
</body>
</html>
body{background-color: #EEEEEE; }
#container{margin: auto;
width: 100%;
background-color: #EEEEEE;
border: 10px solid #EEEEEE;
}
#header{
background-color: #449966;
height: 110px;
margin-top: 38px;
}
#nav{background-color: #000000;
clear: left;
}
#moira{
float:right;
padding-right: 50px;
position: relative;
margin-left: 50px;
}
#martin{
float:right;
padding-right: 50px;
position: relative;
margin-left: 50px;
}
#openinghours{`
width: 30%;
float:left;
margin-left: 100px;}
#contactus{width: 50%;
float:left;
margin-bottom: 200px;}
#content{background-color: #EEEEEE;
padding: 50px;
min-height: 500px;
text-align: center;
}
#content a {background-color: #449966; color: white; text-decoration:none; padding:5px;}
#content a:hover {background-color: #878787; color: white;}
#footer{background-color: #449966;
height: 50px;
padding: 10px;
display: flex;
margin-top: 200px;
bottom: 0;
width: 100%;
position: fixed;
}
#comments {width: 70%; float: left;}
.container{
position: relative;
border-radius: 8px;
width: 90%;
height: 500px;
overflow: hidden;
}
#login{z-index: 100;}
#logo {float:left;}
#copyright {float:left;}
#footer ul{ text-align: center;
width: 50%;
margin: auto;}
#footer a{ color:#449966; }
#socialMedia{float:right; width: 150px; display: flex;}
#sitename{text-align: center;
width: 100%;}
#languageimage img{
border: 1px solid #ddd;
border-radius: 50%;
float:right;
display: flex;
vertical-align: top;}
table td {padding: 10px;}
table {width: 100%}
table tr:nth-child(1) {
background-color: #449966;
}
table tr {
background-color:#FFFFFF;
}
#displayproperties{width: 75%;}
#addtestimonial{width: 25%; margin-left: 50px; float: right;}
#addtestimonial table {border: 0px;}
#addtestimonial table tr td {padding: 0px; border: 0px;}
#addtestimonial table tr {background-color: #c6e1e0; border: 0px;}
.show {display:block;}
#commentform {
font-family: Arial;
width: auto;
}
label { float:left;
width: 50px;
clear: left;
text-align: left;
padding-right: 15px;
margin-top: 10px;
}
input, textarea {margin-top: 10px; }
#mysubmit { margin-left:65px;
padding-bottom: 10px;
}
body {margin:0;font-family:Arial}
.topnav {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #449966;
color: white;
}
.topnav .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: fixed;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
#youtubewaw{margin-bottom: 200px;}
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #449966;
color: white;
}
.dropdown-content a:hover {
background-color: #449966;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media only screen and (max-width: 1200px) {
#openinghours{float:none;}
#addtestimonial{float:none;}
#media only screen and (max-width: 768px) {
body{font-size:90%;}
#displayproducts td:nth-child(1){display:none;}
#commentform{width: auto; font-size: 80%;}
#mysubmit{margin-left: 0;}
#openinghours{float:none;}
td:nth-of-type(4){display:none;}
#content{ padding: 0px;}}
#media screen and (max-width: 768px) {
#sitename{display:none;}
.topnav a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 768px) {
#sitename{display:none;}
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
I noticed you have an accidental ` character.
#openinghours{`
width: 30%;
float:left;
margin-left: 100px;}
Also you've got some id called #mysubmit but your submit input doesn't use that ID.
I removed the below and everything works again. I don't understand why but I am fairly new to this
.container{
position: relative;
I am using PHP sessions to to provide specific forms on a page and need to toggle between a "show form" link and the form. I have this working using jQuery toggle(), but I cannot figure out how to prevent the "show form" link from displaying in both toggle states.
I have experimented with jQuery hide() after toggle(), but this made everything disappear, and I have tried using CSS visibility: hidden (which also just caused everything, including the PHP content, to disappear).
<div id="togLink">
<?php echo $JQclick; ?>
</div>
<div id="showForm">
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/formInc.php'; ?>
</div>
<script>
function toggleForm() {
$("#showForm").toggle();
$("#togLink").toggle();
}
$("#togLink").click(function() {
toggleForm();
});
$("#showForm").click(function() {
toggleForm();
});
</script>
The above code works, but the PHP output is displayed in both toggle states (which, I know, is the expected behaviour). As I said above, I need some way of making the toggle state "either or" - clickable link or form, not both. Can anyone offer any suggestions for this?
...
...
CSS code:
#font-face {
font-family: 'blair_capsregular';
src: url('../.typefaces/blair_caps-webfont.woff2') format('woff2'),
url('../typefaces/blair_caps-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
#ExBox {
width: 600px;
margin: 50px auto 0 auto;
text-align: justify;
font-family: verdana, arial, sans-serif;
font-size: 11px;
line-height: 1.6;
}
.titleBar {
width:100%;
}
.Tbox {
float:left; height:25px;
text-align: center;
font-size: 15px;
font-family: 'blair_capsregular';
}
#box {
border: 2px solid blue;
margin: 0;
position: static;
padding: 0 2px 0 2px;
text-decoration: none;
}
#box a:link {
color: orange;
text-decoration: none;
}
#box a:visited {
color: orange;
text-decoration: none;
}
.Tbox:nth-child(1) {
width:33.3%;
}
.Tbox:nth-child(2) {
width:33.3%;
}
.Tbox:nth-child(3) {
width:33.3%;
}
.clearRed {
clear: both;
color: red;
}
.Tbox a:link {
color: black;
text-decoration: none;
}
.Tbox a:visited {
color: black;
text-decoration: none;
}
.Tbox a:hover {
color: red;
text-decoration: none;
}
.Tbox a:active {
color: hotpink;
text-decoration: none;
}
.Tbox a:focus {
color: hotpink;
text-decoration: none;
}
/* FORM CSS - Placeholder colors */
::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color: #9b9b9b;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #9b9b9b;
opacity: 1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #9b9b9b;
opacity: 1;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: #9b9b9b;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: #9b9b9b;
}
textarea::placeholder { color: #9b9b9b; font-family: arial; }
/* Colors for focused fields */
input[type=text], input[type=email], textarea {
outline: none;
border: 1px solid #9b9b9b;
}
input[type=text]:focus, input[type=email]:focus, textarea:focus {
border: 1px solid #00C5BE;
}
/* Input styling */
textarea {
font-family: arial;
width: 27rem;
font-size: 1rem;
padding: 0.6rem;
margin-right: 0.5rem;
margin-left: 0.5rem;
border-radius: 5px;
border: 1px solid #9b9b9b;
color: #9b9b9b !important;
}
.contact-form-div input {
display: block;
font-size: 1rem;
width: 27rem;
padding: 0.6rem;
margin: 0.5rem;
border-radius: 5px;
border: 1px solid #9b9b9b;
color: #9b9b9b !important;
}
.contact-form-div input[type=submit] {
width: auto;
background-color: #00C5BE;
border: none;
color: #fff !important;
font-size: 1em;
padding: 10px 50px;
text-transform: uppercase;
font-weight: normal;
}
/* Hide the fake field */
#m66 {
display: none;
}
/* VERTICAL SLIDER */
* { margin:0; padding:0; }
a { text-decoration: none; }
.expand {
background: #fff;
overflow: hidden;
color: #000;
line-height: 50px;
transition: all .5s ease-in-out;
height: 0;
}
.expand:target {
height: 50px;
}
.close {
max-height: 0;
}
/* JQUERY TESTING */
.box{
display:none;
}
#showForm {
display: none;
}
...
...
Thanks to Grant Noe this is almost working. With the above code everything works perfectly ...except that clicking on the form causes it to disappear. Grant has since revised the code (again, thanks); but the revised code, whilst addressing the problem of the disappearing form, has a visible "contact form" link in both toggle states and loads the form first, not the link. The latter should be simple to fix; but I cannot figure out how to show either the contact form link or the form, not both in both toggle states.
The code, when using Grant's revised code, is as follows:
<div id="togLink">
<?php echo $JQclick; ?>
</div>
<div id="showForm">
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/form.php'; ?>
</div>
<script>
$("#togLink").click(function() {
$("#showForm").toggle();
$("#contactForm").toggle();
});
</script>
#font-face {
font-family: 'blair_capsregular';
src: url('../.typefaces/blair_caps-webfont.woff2') format('woff2'),
url('../typefaces/blair_caps-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
#ExBox {
width: 600px;
margin: 50px auto 0 auto;
text-align: justify;
font-family: verdana, arial, sans-serif;
font-size: 11px;
line-height: 1.6;
}
.titleBar {
width:100%;
}
.Tbox {
float:left; height:25px;
text-align: center;
font-size: 15px;
font-family: 'blair_capsregular';
}
#box {
border: 2px solid blue;
margin: 0;
position: static;
padding: 0 2px 0 2px;
text-decoration: none;
}
#box a:link {
color: orange;
text-decoration: none;
}
#box a:visited {
color: orange;
text-decoration: none;
}
.Tbox:nth-child(1) {
width:33.3%;
}
.Tbox:nth-child(2) {
width:33.3%;
}
.Tbox:nth-child(3) {
width:33.3%;
}
.clearRed {
clear: both;
color: red;
}
.Tbox a:link {
color: black;
text-decoration: none;
}
.Tbox a:visited {
color: black;
text-decoration: none;
}
.Tbox a:hover {
color: red;
text-decoration: none;
}
.Tbox a:active {
color: hotpink;
text-decoration: none;
}
.Tbox a:focus {
color: hotpink;
text-decoration: none;
}
/* FORM CSS - Placeholder colors */
::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color: #9b9b9b;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #9b9b9b;
opacity: 1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #9b9b9b;
opacity: 1;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: #9b9b9b;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: #9b9b9b;
}
textarea::placeholder { color: #9b9b9b; font-family: arial; }
/* Colors for focused fields */
input[type=text], input[type=email], textarea {
outline: none;
border: 1px solid #9b9b9b;
}
input[type=text]:focus, input[type=email]:focus, textarea:focus {
border: 1px solid #00C5BE;
}
/* Input styling */
textarea {
font-family: arial;
width: 27rem;
font-size: 1rem;
padding: 0.6rem;
margin-right: 0.5rem;
margin-left: 0.5rem;
border-radius: 5px;
border: 1px solid #9b9b9b;
color: #9b9b9b !important;
}
.contact-form-div input {
display: block;
font-size: 1rem;
width: 27rem;
padding: 0.6rem;
margin: 0.5rem;
border-radius: 5px;
border: 1px solid #9b9b9b;
color: #9b9b9b !important;
}
.contact-form-div input[type=submit] {
width: auto;
background-color: #00C5BE;
border: none;
color: #fff !important;
font-size: 1em;
padding: 10px 50px;
text-transform: uppercase;
font-weight: normal;
}
/* Hide the fake field */
#m66 {
display: none;
}
/* VERTICAL SLIDER */
* { margin:0; padding:0; }
a { text-decoration: none; }
.expand {
background: #fff;
overflow: hidden;
color: #000;
line-height: 50px;
transition: all .5s ease-in-out;
height: 0;
}
.expand:target {
height: 50px;
}
.close {
max-height: 0;
}
/* JQUERY TESTING */
.box{
display:none;
}
#togLink {
color: blue;
cursor: pointer;
}
#togLink:hover {
text-decoration: underline;
}
#showForm,
#contactForm {
width: 425px;
height: 550px;
}
#showForm {
background-color: #DDD;
}
#contactForm {
background-color: #AAA;
display: none;
}
I have not added-in contactForm to the HTML side of things, because it does not fix the persistent "contact form" link and leaves an ugly background-colour box behind even when hiding the form but failing to hide the link.
...
...
26 May 2019: with reference to a reply by rg88 [ How do I hide a part of a form and make it visible only on clicking a "Add another" button? ] this is what finally worked:
<a id="togLink" href="#"><?php echo $formClick; ?></a>
<div id="togForm"><?php require_once $_SERVER["DOCUMENT_ROOT"] . '/form.php'; ?>
</div>
<script>
$( "#togLink" ).on( "click", function() {
$('#togForm').toggle();
});
</script>
#togForm {
display: none;
}
There is still the issue of not being able to make the words "Contact Form" disappear when the form is loaded or being able to replace the words with something else, but it appears that it is not possible to make this happen because the Contact Form link (in this case) is the toggle point and therefore has to remain constant in all toggle states.
You're toggling just the one element right now, given this format: $(toggled-element).toggle();. You'll need to toggle both elements like this:
$('#togLink').click(function(){
$('#showForm').toggle();
$('#contactForm').toggle();
});
If you initially want the link showing and the form hidden, you could hide the form with css with display: none;, or at the top of your html in a script with $('#showForm').hide();. So the total result would be something like this:
$("#togLink").click(function() {
$("#showForm").toggle();
$("#contactForm").toggle();
});
#togLink {
color: blue;
cursor: pointer;
}
#togLink:hover {
text-decoration: underline;
}
#showForm,
#contactForm {
width: 425px;
height: 550px;
}
#showForm {
background-color: #DDD;
}
#contactForm {
background-color: #AAA;
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="togLink">Toggle Form</div>
<div id="showForm"></div>
<div id="contactForm"></div>
Let me know if I missed something.
Changelog:
I added the #contactForm div that's not seen in OP to adjust to OP use-case requests. The clarification occurred in the comments on my answer.
Placing the PHP in an HTML element allows you to have separate control over that element:
<div id="togLink">foo
<?php echo $JQclick; ?>
</div>
<div id="showForm">bar
<span>glorp<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/formInc.php'; ?></span>
</div>
Use CSS to hide the element:
span {
display: none;
}
Then avoid the element to be toggled, using .not():
$('#togLink').click(function(){
console.log('click');
$('#showForm').not('span').toggle();
});
Here is a DEMO
I am setting up an ID card printing software in PHP both for landscape and portrait mode. The problem is with the print() command it always takes the standard page sizes A4, A3... Because of this it prints the id in a specific section of the card.
Can anyone help or recommend something? Perhaps there is another way to print it without print preview in chrome?
<style>
#page {
/*size: A5;
margin: 5px;*/
width: 53.98mm;
height: 85.60mm;
margin: 0px;
}
#media print {
html, body {
/*width: 210mm;
height: 297mm;*/
/*width: 218mm;
height: 340mm;*/
}
}
#printablediv {
width: 53.98mm;
height: 85.60mm;
}
.idcardreport {
font-family: arial;
-webkit-print-color-adjust: exact;
}
/*IDcard Front Part Css Code*/
.idcardreport-frontend{
margin: 2px;
float: left;
border: 1px solid #000;
padding: 10px;
width: 260px;
text-align: center;
height:370px;
background-size: 100% 100% !important;
}
.logo img{
width: 50px;
height: 50px;
border: 1px solid #ddd;
margin-bottom: 5px;
}
.pick img{
width: 60px;
height: 80px;
border: 1px solid #ddd;
margin-bottom: 5px;
}
.signe img{
width: 50px;
height: 50px;
border: 1px solid #ddd;
margin-bottom: 5px;
}
h3 {
font-size: 14px;
color: #1A2229;
text-align: center;
}
h2 {
font-size: 10px;
color: #1A2229;
text-align: center;
}
h1 {
font-size: 18px;
color: #1A2229;
text-align: center;
}
p {
text-align: left;
font-size: 12px;
margin-bottom: 0px;
margin-top: 1px;
color: #1A2229;
}
.vertical{
writing-mode:tb-rl;
-webkit-transform:rotate(180deg);
-moz-transform:rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform:rotate(180deg);
transform: rotate(180deg);
white-space:nowrap;
display:block;
bottom:0;
}
</style>
<style>
#media print {
body * {
visibility: hidden;
}
#section-to-print, #section-to-print * {
visibility: visible;
}
#section-to-print {
position: absolute;
left: 0px;
/*right: -400px;*/
top: 0;
}
}
button.btn.btn-dark {
padding: 10px;
position: relative;
top: -390px;
}
</style>
<button type="button" class="btn btn-dark" onclick="window.print()"><i class="fa fa-print"></i> Print</button>
<div class="wrapper" id="section-to-print"></div> //add ID on the section u want to print
As you can see from the picture above , my button will not line properly if they had content inside them.
Please enlighten me why
[ EDIT ]
CSS
.button {
position: relative;
background-color: #4CAF50;
border: 2px solid black;
color: #FFFFFF;
padding: 0;
width: 250px;
height: 200px;
text-align: center;
font-size: 20px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
text-decoration: none;
overflow: hidden;
cursor: pointer;
margin-bottom: 2px;
}
and here is my button
<button class="button" id="Btn2"><span>(2)<br><?php
$id=$_GET['room'];
$day="02";
$month=date("m");
$year=date("Y");
( SQL retrieve data )
$i=1;
while ($reserve = mysqli_fetch_array($result2)){ echo $i.". ".$reserve['room_name']." ".$reserve['start_time']." - ".$reserve['end_time']."<br>";
$i++;
}
?> </span></button>
the answer would be css styling ,
which is
vertical-align:bottom;