Responsive page is not working in table - html

Currently for this project i am using bootstrap and my personal css files. I have defined page wrapper class to differentiate between menu item and content.
The table is working fine in broad view. Working(desktop view)
But while in mobile view half of the content displayed in dark background
Mobile view(not working)
code:
Php code for the Page:
<?php
include "includes/header.php"
?>
<div id="wrapper">
<!-- Navigation Bar -->
<?php include "includes/navigation.php" ?>
<div id="page-wrapper">
<div class="container-fluid">
<?php
$query = "SELECT * FROM patent_details where sap_id='$sap'";
$result = mysqli_query( $conn, $query );?>
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header dash-head">
<center>Patent View</center> <!-- All data defined here-->
</h1>
<table class="table">
<thead>
<th>Patent ID</th>
<th>Author other than UPES</th>
<th>Department</th>
<th>File Application No</th>
<th>Filling Date</th>
<th>Country</th>
<th>Patent Status</th>
<th>Currency</th>
<th>Income Generated</th>
</thead>
<tbody>
<?php
if( mysqli_num_rows($result) > 0 ) {
while( $row = mysqli_fetch_assoc($result) ) {
$patent_id = $row['patent_id'];
$auther_other_than_UPES = $row['author_other_than_UPES'];
$department = $row['department'];
$file_application_no = $row['file_application_no'];
$filing_date = $row['filing_date'];
$country = $row['country'] ;
$patent_status = $row['patent_status'];
$currency = $row['currency'];
$income_generated = $row['faculty_income_generated_through_patents'];
echo "<tr>";
echo "<td>$patent_id</td>";
echo "<td>$auther_other_than_UPES</td>";
echo "<td>$department</td>";
echo "<td>$file_application_no</td>";
echo "<td>$filing_date</td>";
echo "<td>$country</td>";
echo "<td>$patent_status</td>";
echo "<td>$currency</td>";
echo "<td>$income_generated</td>";
echo "<td><a type='button' href='patent_edit.php?id=".$patent_id."' >Edit</a>;</td>";
echo "</tr>";
}
}
else {
echo "No data available";
}
?>
</tbody>
</table>
<?php include "includes/footer.php"
?>
CSS code for the page:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin-top: 100px;
background-color: #222;
}
#media(min-width:768px) {
body {
margin-top: 50px;
}
}
#wrapper {
padding-left: 0;
}
#page-wrapper {
width: 100%;
padding: 0;
background-color: #fff;
}
#media(min-width:768px) {
#wrapper {
padding-left: 225px;
}
#page-wrapper {
padding: 10px;
}
}
/* Top Navigation */
.top-nav {
padding: 0 15px;
}
.top-nav>li {
display: inline-block;
float: left;
}
.top-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
line-height: 20px;
color: #999;
}
.top-nav>li>a:hover,
.top-nav>li>a:focus,
.top-nav>.open>a,
.top-nav>.open>a:hover,
.top-nav>.open>a:focus {
color: #fff;
background-color: #000;
}
.top-nav>.open>.dropdown-menu {
float: left;
position: absolute;
margin-top: 0;
border: 1px solid rgba(0,0,0,.15);
border-top-left-radius: 0;
border-top-right-radius: 0;
background-color: #fff;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
.top-nav>.open>.dropdown-menu>li>a {
white-space: normal;
}
/* Side Navigation */
#media(min-width:768px) {
.side-nav {
position: fixed;
top: 51px;
left: 225px;
width: 225px;
margin-left: -225px;
border: none;
border-radius: 0;
overflow-y: auto;
background-color: #222;
}
.side-nav>li>a {
width: 225px;
}
.side-nav li a:hover,
.side-nav li a:focus {
outline: none;
background-color: #000 !important;
}
}
.side-nav>li>ul {
padding: 0;
}
.side-nav>li>ul>li>a {
display: block;
padding: 10px 15px 10px 38px;
text-decoration: none;
color: #999;
}
.side-nav>li>ul>li>a:hover {
color: #fff;
}
.navbar-inverse .navbar-brand {
color: #ff4500;
font-size: 25px;
}
.dash-head{
font-size: 40px;
color: #ff4703;
}
p{
font-size: 15px;
padding: 0;
}
.dash-list{
list-style: none;
}
footer {
position: fixed;
right: 0;
bottom: 0;
left: 0;
padding:0;
color: #fff;
background-color: #555;
text-align: center;
}

As you mentioned you are using bootstrap, in order to make your table responsive you should just make use of the classes available within the framework. I.e:
<table class='table table-responsive'>
//Rest of table here
</table>
You can find the complete documentation here: http://getbootstrap.com/css/#tables

Although you used bootstrap you haven't done anything to make the table responsive.
<div class="table-responsive">
<table class="table">
//Code
</table>
</div>
Use above mentioned code. I hope you will get what you wanted.

Related

div not taking full width of screen on mobile, when there's a wide table underneath

Having read a lot of other posts for 'div not taking full width', I still can't find an answer as to why the following happens with my website:
I have a responsive topnav navigation bar that works perfectly in Chrome on a Win11 machine. On an Android mobile however, the topnav only takes the full width of the browser when the table is less 'narrow'. It seems that when the table becomes wider, the topnav doesn't follow suit.
HTML + PHP:
<?php
// Include the database connection file
include_once("config.php");
$usr = $_GET['usr'];
// Fetch measurements (in descending order)
$result = mysqli_query($mysqli, "SELECT * FROM ".$usr." ORDER BY ts DESC");
?>
<!DOCTYPE html>
<html lang="nl">
<head>
<title>MariaDB Bloeddruk</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>
<div class="topnav" id="myTopNav">
<?php include("../header.php") ?>
</div>
<div>
<table>
<thead>
<tr>
<th>Datum</th>
<th>Tijd</th>
<th>Bovendruk</th>
<th>Onderdruk</th>
<th>Hoge Bloeddruk</th>
<th>Hartslag</th>
<th>Onregelmatige Hartslag</th>
<th>AF Modus</th>
<th>AF gedetecteerd</th>
<th>Manchet OK</th>
<th><a class="button" href="add.php?usr=<?php echo $usr ?>">Nieuwe meting</a></th>
</tr>
</thead>
<tbody>
<?php
// Print measurements
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
$dt = substr($res['ts'],0,10);
$tm = substr($res['ts'],-8,8);
echo "<td>".$dt."</td>";
echo "<td>".$tm."</td>";
echo "<td>".$res['sys_bp']."</td>";
echo "<td>".$res['dia_bp']."</td>";
echo "<td><input ".($res['high_bp'] == 1 ? "checked" : "")." type='checkbox' onclick='return false;'</td>";
echo "<td>".$res['hr']."</td>";
echo "<td>".($res['irregular_rythm'] == '' ? "</td>" : "<input ".($res['irregular_rythm'] == 1 ? "checked" : "")." type='checkbox' onclick='return false;'</td>");
echo "<td><input ".($res['af_mode'] == 1 ? "checked" : "")." type='checkbox' onclick='return false;'</td>";
echo "<td>".($res['af_detected'] == '' ? "</td>" : "<input ".($res['af_detected'] == 1 ? "checked" : "")." type='checkbox' onclick='return false;'</td>");
echo "<td><input ".($res['cuff_ok'] == 1 ? "checked" : "")." type='checkbox' onclick='return false;'</td>";
echo "<td>Bewerken | Verwijderen</td>";
}
?>
</tbody>
</table>
</div>
</body>
</html>
rendered HTML/code snippet:
body {
font-family: Verdana, Tahoma, sans-serif;
font-size: calc(16px + 0.25vw);
}
.topnav {
overflow: hidden;
background-color: #a6e1fa;
margin-bottom: 20px;
position: sticky;
top: 0;
}
.topnav a {
float: left;
display: block;
color: #fff;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.topnav a:hover {
background-color: #bbb;
color: black;
}
.topnav a.active {
background-color: #001c55;
color: white;
}
.topnav .icon {
display: none;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
a {
color: #0a2472;
text-decoration: none;
padding: 6px;
}
table {
border-collapse: collapse;
border: 1px solid #0e6ba8;
margin-left: auto;
margin-right: auto;
}
table th {
background-color: #0e6ba8;
color: #fff;
font-weight: bold;
padding: 18px 12px;
position: sticky;
top: 0;
}
table tr:nth-child(even) {
background-color: #caf0f8;
}
table tr {
border-bottom: 1px dotted #0e6ba8;
}
table td {
padding: 12px;
text-align: center;
}
table td:first-child {
white-space: nowrap;
}
form table {
width: 33%;
}
form table tr:nth-child(even) {
background-color: #fff;
}
form table tfoot {
background-color: #0e6ba8;
}
form table td:first-child {
white-space: normal;
}
.button {
border: 1px solid #001c55;
border-radius: 10px;
background-color: #001c55;
color: #fff;
text-decoration: none;
padding: 6px;
min-width: 100px;
white-space: nowrap;
}
.button:hover {
background-color: #fff;
color: #001c55;
cursor: pointer;
}
input {
font-size: inherit;
}
input[type=number] {
width: calc(4 * (16px + 0.25vw));
text-align: center;
}
input[type=checkbox] {
width: calc(16px + 0.25vw);
height: calc(16px + 0.25vw);
}
input[type=checkbox]:checked {
accent-color: #0a2472;
background-color: #000;
}
input[type=submit] {
border: 1px solid #001c55;
border-radius: 10px;
background-color: #001c55;
color: #fff;
text-decoration: none;
padding: 10px;
min-width: 100px;
}
input[type=submit]:hover {
background-color: #fff;
color: #001c55;
cursor: pointer;
}
input[type=submit].cancel {
background-color: #bbb;
background-color: #bbb;
border: 1px solid #bbb;
}
input[type=submit].cancel:hover {
background-color: #fff;
color: #bbb;
cursor: pointer;
}
.float-right {
float: right;
}
.error {
color: red;
font-size: 12px;
}
<html lang="nl"><head>
<title>MariaDB Bloeddruk</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>
<div class="topnav" id="myTopNav">
HomeBloeddruk - JoostVijverwaterWatermeterWaterlekkage <i class="fa fa-bars"></i></div>
<div>
<table>
<thead>
<tr>
<th>Datum</th>
<th>Tijd</th>
<th>Bovendruk</th>
<th>Onderdruk</th>
<th>Hoge Bloeddruk</th>
<th>Hartslag</th>
<th>Onregelmatige Hartslag</th>
<th>AF Modus</th>
<th>AF gedetecteerd</th>
<th>Manchet OK</th>
<th><a class="button" href="add.php?usr=joost">Nieuwe meting</a></th>
</tr>
</thead>
<tbody>
<tr><td>2022-10-29</td><td>09:23:00</td><td>140</td><td>80</td><td><input checked="" type="checkbox" onclick="return false;" <="" td=""></td><td>50</td><td></td><td><input type="checkbox" onclick="return false;" <="" td=""></td><td></td><td><input type="checkbox" onclick="return false;" <="" td=""></td><td>Bewerken | Verwijderen</td></tr></tbody>
</table>
</div>
</body></html>
Got it solved by adding max height/width and auto overflow to the div containing the table:
CSS added:
.tableContainer {
max-width: 100vw;
max-height: 100vh;
overflow:auto;
}
And of course classified the div that wraps the table as "tableContainer":
<div class="tableContainer">
<table>
<thead>
<tr>
<th>Datum</th>
...

How do I put a border around each table box?

I am having trouble while putting a table border around each box in the table, its just showing the table without the borders.
I want it to show the table with the borders.
I have tried using the css for table borders in w3schools and it doesn't seem to work, I also added an !important tag to it and it still seemed to not work...
html:
<!DOCTYPE html>
<?php
$database = "seriousdiseases";
$database = new mysqli('localhost', 'root', '', $database) or die ("Unable to connect to the
DB");
?>
<html>
<head>
<title>Ribose-5-phosphate isomerase deficiency</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div id="container2">
<div id="header">
<h1>Ribose-5-phosphate isomerase deficiency</h1>
</div>
<div id="content">
<div id="nav">
<h3>Navigation</h3>
<ul>
<li>Home</li>
<li>About Me</li>
<li>Video</li>
<li>Serious Diseases</li>
<li>Update Diseases</li>
<img src="F1large.jpg" alt="Navigation Picture." style="height:500px;">
</ul>
</div>
<div id="main">
<table>
<tr>
<th>Id</th>
<th>Disease</th>
<th>Symptoms</th>
</tr>
<?php
$result = mysqli_query($database, "select * from feature") or die
("Unable to connect to the DB");
while ($row = mysqli_fetch_array($result)){
print("<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td><td>"
. $row[2] . "</td></tr>");
}
$database->close();
?>
</table>
</div>
</div>
</div>
<div id="footer">
Copyright © 2020 CLINIC SCOPE
</div>
</body>
</html>
css:
html, body {
height: 100%;
}
body {
background-color: #EEE;
font-family: Helvetica, Arial, sans-serif;
background-image: url (logo.png);
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
display: flex;
flex-direction: column;
}
table, th, td{
border: 1px solid black !important;
}
h1, h2, h3 {
margin: 0;
}
a {
text-decoration: none;
color: blue;
}
#container {
background-color: white;
margin-left: 0px;
margin-right: 0px;
position: relative;
min-height: 97.7vh;
}
#container2 {
background-color: white;
margin-left: 0px;
margin-right: 0px;
position: relative;
}
#header {
background-color: blue;
color: white;
text-align: center;
padding: 10px;
}
#content {
padding:10px;
margin-right:0px;
}
#nav ul {
list-style-type: none;
}
#nav .selected {
font-family: bold;
}
#nav {
width: 18%;
float: left;
}
#main {
width: 60%;
float: right;
}
#footer {
color: white;
background-color: black;
width: 100%;
text-align: center;
position: relative;
bottom: 0;
}
Try to add this attribute in your table tag <table border = "4">

Why is the input taking up 2 spaces?

I have a problem with my input.
As you can see, my input is taking up too much space. It doesn't have margin or padding.
Here's my code (I am using Boilerplate v5.3.0).
How can I fix it so it just takes the space that it needs?
$(document).ready(function() {
$('.selectList').hide();
$('.selectorWrapper a').click(function() {
hideShow(this);
});
$('ul.selectList li').click(function() {
changeText(this);
validate();
});
$('#email').keydown(function() {
var correo = $('#email').val();
if (validateMail(correo)) {
$('#email').css('borderColor', '#87e466');
validate();
} else {
$('#email').css('borderColor', '#ca3535');
validate();
}
});
function validateMail(email) {
var re = /^(([^<>()\[\]\\.,;:\s#"]+(\.[^<>()\[\]\\.,;:\s#"]+)*)|(".+"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
console.log(re.test(email));
return re.test(email);
}
function validate() {
var select1 = $('#selection1').text();
var select2 = $('#selection2').text();
var select3 = $('#selection3').val();
var email = $('#email').val();
if (select1 != 'Marca' && select2 != 'Modelo' && select3 != 'Anio' && validateMail(email)) {
$('#submitBtn').css({
'backgroundColor': '#bbd550',
'boxShadow': '0px 3px 0px 0px #9fbc2d'
});
$('#submitBtn').removeClass('disableClick');
} else {
$('#submitBtn').css({
'backgroundColor': '#808080',
'boxShadow': '0px 3px 0px 0px #636161'
});
$('#submitBtn').addClass('disableClick');
}
}
function hideShow(element) {
var thisId = $(element).attr('id');
var isHidden = $('#' + thisId).next().css('display');
console.log(isHidden);
if (isHidden == 'none') {
$('#' + thisId).next().slideDown();
} else {
$('#' + thisId).next().slideUp();
}
}
function changeText(element) {
var text = $(element).text();
$(element).parent().prev().text(text);
$(element).parent().prev().append('<i class="fa fa-chevron-down"></i>');
$(element).parent().slideUp();
$(element).parent().prev().css('borderColor', '#87e466')
}
});
html {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input {
outline: none;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
.disableClick {
pointer-events: none;
}
label {
display: none;
}
h3,
h2 {
margin: 0 auto;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
header.site-header {
background-color: #000000;
width: 100%;
}
header.site-header h3 {
text-align: center;
color: #ffffff;
padding: 15px 0;
font-weight: normal;
font-size: 30px;
}
header.site-header h3 span {
font-weight: bold;
}
div.banner {
border-bottom: 5px solid #36aadd;
}
div.banner h2 {
font-size: 2em;
text-align: center;
font-weight: bold;
color: #36aadd;
padding: 15px 10px 10px 10px;
}
div.banner p {
color: #888888;
text-align: center;
margin: 0;
font-size: 1.2em;
padding-bottom: 50px;
font-family: 'Open Sans', sans-serif;
}
div.form {
padding: 20px 10px;
margin: 0;
background-color: #eeeeee;
}
a.selectButton {
text-decoration: none;
padding: 10px;
color: #888888;
background-color: #ffffff;
border: 1px solid #d0d0d0;
display: block;
width: 100%;
margin: 0;
}
a.selectButton i {
color: #d0d0d0;
float: right;
padding-right: 10px;
}
ul.selectList {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #d0d0d0;
width: 100%;
position: absolute;
}
ul.selectList li {
width: 100%;
padding: 10px 0 10px 10px;
display: block;
background-color: #ffffff;
}
ul.selectList li a {
display: block;
text-decoration: none;
color: #888888;
}
ul.selectList li:hover {
background-color: #d0d0d0;
}
div.selectorWrapper input {
margin: 0;
padding: 10px;
width: 100%;
border: 1px solid #d0d0d0;
border-top: none;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
div.selectorWrapper {
/*width:100%;*/
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 50%;
float: left;
}
div.selectorWrapper .button {
background-color: #808080;
color: #FFFFFF;
margin-top: 30px;
border-radius: 4px;
margin-bottom: 20px;
font-size: 30px;
box-shadow: 0px 3px 0px 0px #636161;
border: none;
font-family: 'Open Sans', sans-serif;
}
div.recuperar {
text-align: center;
padding: 20px;
}
div.recuperar a.recupera-link {
text-decoration: none;
color: #5faadb;
font-size: 18px;
font-family: 'Open Sans', sans-serif;
}
.contenedorA {
position: relative;
}
#media only screen and (min-width: 768px) {
label {
display: block;
width: 30%;
float: left;
padding: 10px 0 0 15px;
text-align: left;
font-size: 0.9em;
}
div.banner {
border: none;
}
div.form {
background: #ffffff;
}
.contenedorA {
padding: 100px 50px 0 50px;
}
.contenedor {
width: 96%;
margin: 0 auto!important;
box-shadow: 0px 0px 10px 3px #f9f9f9;
margin-top: 50px;
}
div.selectorWrapper {
width: 80%;
margin: 20px auto;
}
div.selectorWrapper input,
div.selectorWrapper a.selectButton {
width: 70%;
float: right;
margin: 0 auto;
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 80%;
float: none;
position: relative;
}
ul.selectList {
position: relative;
margin-left: 420px;
margin-top: 44px;
}
div.selectorWrapper input {
border: 1px solid #d0d0d0;
}
div.recuperar {
padding-left: 100px;
}
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel='stylesheet' href='css/main.css' type="text/css">
<!--<link rel='stylesheet' href='css/normalize.css' type="text/css">-->
</head>
<body>
<header class='site-header'>
<h3><span>compara</span>online</h3>
</header>
<div class=contenedorA>
<div class="contenedor">
<div class="banner">
<h2>Cotiza tu Seguro Automotriz</h2>
<p>Resultados instantaneos!</p>
</div>
<div class="form clearfix">
<form method="post" action="">
<div class="selectorWrapper clearfix">
<label>Marca : </label>
<a class="selectButton" id="selection1" href="#">Marca<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Hyundai</li>
<li>Toyota</li>
<li>Nissan</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Modelo : </label>
<a class="selectButton" id="selection2" href="#">Modelo<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Sedan</li>
<li>SUV</li>
<li>Pick-up</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Anio: </label>
<a class="selectButton" id="selection3" href="#">Anio<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>2017</li>
<li>2016</li>
<li>2015</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<!--<label>Email : </label>-->
<input type='email' name='email' class="clearfix" id='email' placeholder='Email' required>
</div>
<div class="selectorWrapper clearfix">
<input type='submit' class="button disableClick" id='submitBtn' value="Cotizar">
</div>
</form>
<div class="recuperar">
<a class="recupera-link" href="#">Recuperar cotizacion</a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src='js/main.js' type="text/javascript"></script>
When you float an element, you remove it from the normal flow of the document. As a result, other block elements don't respect their space.
Since both elements on the line (Modelo and Anio) are float: left, the next block element (Email) doesn't see them, and takes their space. So the Email div now lies hidden under the split elements.
However, the input element inside the Email div is not a block element. It's an inline element, by default. And inline elements respect the space of floated elements. (This is how text is able to wrap around floated images.)
So in your code, while the Email div shifts below the split element (on the z-axis), the input inside the Email div stays below the split element (on the y-axis).
When you highlight the Email element in dev tools, it illustrates this split across two rows.
One solution is to give the Email div display: inline-block and width: 100%.
div.selectorWrapper:nth-child(4) {
display: inline-block;
width: 100%;
}
Another solution is to add clear: both to the Email div. (Read more about clearing floats.)
div.selectorWrapper:nth-child(4) {
clear: both;
}
$(document).ready(function() {
$('.selectList').hide();
$('.selectorWrapper a').click(function() {
hideShow(this);
});
$('ul.selectList li').click(function() {
changeText(this);
validate();
});
$('#email').keydown(function() {
var correo = $('#email').val();
if (validateMail(correo)) {
$('#email').css('borderColor', '#87e466');
validate();
} else {
$('#email').css('borderColor', '#ca3535');
validate();
}
});
function validateMail(email) {
var re = /^(([^<>()\[\]\\.,;:\s#"]+(\.[^<>()\[\]\\.,;:\s#"]+)*)|(".+"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
console.log(re.test(email));
return re.test(email);
}
function validate() {
var select1 = $('#selection1').text();
var select2 = $('#selection2').text();
var select3 = $('#selection3').val();
var email = $('#email').val();
if (select1 != 'Marca' && select2 != 'Modelo' && select3 != 'Anio' && validateMail(email)) {
$('#submitBtn').css({
'backgroundColor': '#bbd550',
'boxShadow': '0px 3px 0px 0px #9fbc2d'
});
$('#submitBtn').removeClass('disableClick');
} else {
$('#submitBtn').css({
'backgroundColor': '#808080',
'boxShadow': '0px 3px 0px 0px #636161'
});
$('#submitBtn').addClass('disableClick');
}
}
function hideShow(element) {
var thisId = $(element).attr('id');
var isHidden = $('#' + thisId).next().css('display');
console.log(isHidden);
if (isHidden == 'none') {
$('#' + thisId).next().slideDown();
} else {
$('#' + thisId).next().slideUp();
}
}
function changeText(element) {
var text = $(element).text();
$(element).parent().prev().text(text);
$(element).parent().prev().append('<i class="fa fa-chevron-down"></i>');
$(element).parent().slideUp();
$(element).parent().prev().css('borderColor', '#87e466')
}
});
div.selectorWrapper:nth-child(4) {
clear: both;
}
html {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input {
outline: none;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
.disableClick {
pointer-events: none;
}
label {
display: none;
}
h3,
h2 {
margin: 0 auto;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
header.site-header {
background-color: #000000;
width: 100%;
}
header.site-header h3 {
text-align: center;
color: #ffffff;
padding: 15px 0;
font-weight: normal;
font-size: 30px;
}
header.site-header h3 span {
font-weight: bold;
}
div.banner {
border-bottom: 5px solid #36aadd;
}
div.banner h2 {
font-size: 2em;
text-align: center;
font-weight: bold;
color: #36aadd;
padding: 15px 10px 10px 10px;
}
div.banner p {
color: #888888;
text-align: center;
margin: 0;
font-size: 1.2em;
padding-bottom: 50px;
font-family: 'Open Sans', sans-serif;
}
div.form {
padding: 20px 10px;
margin: 0;
background-color: #eeeeee;
}
a.selectButton {
text-decoration: none;
padding: 10px;
color: #888888;
background-color: #ffffff;
border: 1px solid #d0d0d0;
display: block;
width: 100%;
margin: 0;
}
a.selectButton i {
color: #d0d0d0;
float: right;
padding-right: 10px;
}
ul.selectList {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #d0d0d0;
width: 100%;
position: absolute;
}
ul.selectList li {
width: 100%;
padding: 10px 0 10px 10px;
display: block;
background-color: #ffffff;
}
ul.selectList li a {
display: block;
text-decoration: none;
color: #888888;
}
ul.selectList li:hover {
background-color: #d0d0d0;
}
div.selectorWrapper input {
margin: 0;
padding: 10px;
width: 100%;
border: 1px solid #d0d0d0;
border-top: none;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
div.selectorWrapper {
/*width:100%;*/
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 50%;
float: left;
}
div.selectorWrapper .button {
background-color: #808080;
color: #FFFFFF;
margin-top: 30px;
border-radius: 4px;
margin-bottom: 20px;
font-size: 30px;
box-shadow: 0px 3px 0px 0px #636161;
border: none;
font-family: 'Open Sans', sans-serif;
}
div.recuperar {
text-align: center;
padding: 20px;
}
div.recuperar a.recupera-link {
text-decoration: none;
color: #5faadb;
font-size: 18px;
font-family: 'Open Sans', sans-serif;
}
.contenedorA {
position: relative;
}
#media only screen and (min-width: 768px) {
label {
display: block;
width: 30%;
float: left;
padding: 10px 0 0 15px;
text-align: left;
font-size: 0.9em;
}
div.banner {
border: none;
}
div.form {
background: #ffffff;
}
.contenedorA {
padding: 100px 50px 0 50px;
}
.contenedor {
width: 96%;
margin: 0 auto!important;
box-shadow: 0px 0px 10px 3px #f9f9f9;
margin-top: 50px;
}
div.selectorWrapper {
width: 80%;
margin: 20px auto;
}
div.selectorWrapper input,
div.selectorWrapper a.selectButton {
width: 70%;
float: right;
margin: 0 auto;
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 80%;
float: none;
position: relative;
}
ul.selectList {
position: relative;
margin-left: 420px;
margin-top: 44px;
}
div.selectorWrapper input {
border: 1px solid #d0d0d0;
}
div.recuperar {
padding-left: 100px;
}
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel='stylesheet' href='css/main.css' type="text/css">
<!--<link rel='stylesheet' href='css/normalize.css' type="text/css">-->
</head>
<body>
<header class='site-header'>
<h3><span>compara</span>online</h3>
</header>
<div class=contenedorA>
<div class="contenedor">
<div class="banner">
<h2>Cotiza tu Seguro Automotriz</h2>
<p>Resultados instantaneos!</p>
</div>
<div class="form clearfix">
<form method="post" action="">
<div class="selectorWrapper clearfix">
<label>Marca : </label>
<a class="selectButton" id="selection1" href="#">Marca<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Hyundai</li>
<li>Toyota</li>
<li>Nissan</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Modelo : </label>
<a class="selectButton" id="selection2" href="#">Modelo<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Sedan</li>
<li>SUV</li>
<li>Pick-up</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Anio: </label>
<a class="selectButton" id="selection3" href="#">Anio<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>2017</li>
<li>2016</li>
<li>2015</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<!--<label>Email : </label>-->
<input type='email' name='email' class="clearfix" id='email' placeholder='Email' required>
</div>
<div class="selectorWrapper clearfix">
<input type='submit' class="button disableClick" id='submitBtn' value="Cotizar">
</div>
</form>
<div class="recuperar">
<a class="recupera-link" href="#">Recuperar cotizacion</a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src='js/main.js' type="text/javascript"></script>
In your question you are showing the properties of div, check properties of a tag inside div. The a tag is having padding:10px;.
This is happening because a.selectButton has padding of 10px. You can remove it completely or you can only remove the left padding to fix the problem.
a.selectButton {
padding-left: 0;
}
Insert the above code in your style tag to fix the problem.

HTML Div Disappears when given Fixed Position

Currently I am developing a Facebook like Messenger. Right now I am working under a chat-area, this thing should be fixed. But if I give position:fixed suddenly div disappear. I don't know what to do.
Here is my HTML/PHP code.
<?php
// Turn off all error reporting
//shop not login users from entering
if(isset($_SESSION['id'])){
$user_id = $_SESSION['id'];
}else{
}
require_once("./inc/connect.inc.php");
?>
<header>
<link rel="stylesheet" href="home - Copy.css" />
<nav>
<h3><a class="h3" href="#">Cp</a></h3>
<div>
<?php
//Start your session
session_start();
//Read your session (if it is set)
if (isset($_SESSION['user_login']))
echo $_SESSION['user_login'];
?>
</div>
<div><span>Logout</span></div>
<div><span>Settings </span></div>
</nav>
<body>
<div class="shead">
<div class="a1"> <li >Frequent Member</li>
<ul>
<?php
//show all the users expect me
$user_id = $_SESSION['id'];
$q = mysql_query("SELECT * FROM `users` WHERE id!='$user_id'");
//display all the results
while($row = mysql_fetch_assoc($q)){
echo "<a href='home.php?id={$row['id']}'><p>{$row['username']}</p></a>";
}
?>
</ul>
</div>
<div class="a2"> <li >Site's Popular in Your College</li></div>
</div>
</header>
<div class="rss">
<?php
//include('rssclass.php');
//sinclude('rss.php');
?>
<div class="message-right">
<!-- display message -->
<div class="display-message">
<?php
//check $_GET['id'] is set
if(isset($_GET['id'])){
$user_two = trim(mysql_real_escape_string( $_GET['id']));
//check $user_two is valid
$q = mysql_query( "SELECT `id` FROM `users` WHERE id='$user_two' AND id!='$user_id'");
//valid $user_two
if(mysql_num_rows($q) == 1){
//check $user_id and $user_two has conversation or not if no start one
$conver = mysql_query( "SELECT * FROM conversation WHERE (user_one='$user_id' AND user_two='$user_two') OR (user_one='$user_two' AND user_two='$user_id')");
//they have a conversation
if(mysql_num_rows($conver) == 1){
//fetch the converstaion id
$fetch = mysql_fetch_assoc($conver);
$conversation_id = $fetch['id'];
}else{ //they do not have a conversation
//start a new converstaion and fetch its id
$q = mysql_query( "INSERT INTO `conversation` VALUES ('','$user_id',$user_two)");
$conversation_id = mysql_insert_id($con);
}
}else{
die("Invalid $_GET ID.");
}
}else {
die("Click On the Person to start Chating.");
}
?>
</div>
<div class="send-message">
<!-- store conversation_id, user_from, user_to so that we can send send this values to post_message_ajax.php -->
<input type="hidden" id="conversation_id" value="<?php echo base64_encode($conversation_id); ?>">
<input type="hidden" id="user_form" value="<?php echo base64_encode($user_id); ?>">
<input type="hidden" id="user_to" value="<?php echo base64_encode($user_two); ?>">
<div class="textbox">
<input class="t_box" type="text" id="message" placeholder="Enter Your Message"/>
<button class="t_btn" id="reply">Reply</button>
<span id="error"></span>
</div>
</div>
</div>
<!--
<div class="textbox">
<form action="#" method="post">
<input type="text" name="msg_body" class="t_box" id="t_box" >
<input type="submit" class="t_btn" id="t_btn" name="submit" value="Send">
</form>
</div>-->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</body>
Here is my css and .message-right is the element where problem occurs.
#import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', Arial, sans-serif;
background-color: #222;
overflow-x: hidden;
text-align: center;
}
header {
position: fixed;
width: 100%;
height: 50px;
background-color: #FFD700;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}
header > nav > div {
float: right;
width: 10.6666%;
height: 100%;
position: relative;
}
header > nav > div > a {
text-align: center;
width: 100%;
height: 100%;
display: block;
line-height: 50px;
color: #222;
transition: background-color 0.2s ease;
text-transform: uppercase;
}
header > nav > div:hover > a {
background-color: rgba(0, 0, 0, 0.1);
cursor: pointer;
}
a{
text-decoration: none;
color: #000;
}
a:hover{
text-decoration: none;
background-color: #FFD700;
font-weight: bolder;
}
h3{
float: left;
height: 100%;
text-align: bottom;
padding-top: 10px;
padding-left: 10px;
}
.h3{
color: #222;
font-size:25px;
}
.nav{
position: fixed;
}
.title-head {
font-size:18px;
font-weight:bold;
text-align:left;
background-color:#F5F6F7;
color:#000;
float: left;
width: 455.33px;
}
.feeds-links {
text-align:left;
width: 455.33;
font-size: 20px;
padding:5px;
border:1px solid #dedede;
padding-top:inherit;
color: #000;
background-color: #FFFFFF;
}
.rss{
float: right;
padding-top: 100px;
}
.h2{
color: #000;
background: #ffd700;
height: 45px;
width: 455.33px;
padding-top: 10px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}
.textarea{
float: left;
padding-top:553px;
width: 455.3px;
position: fixed;
}
.t_box{
float: left;
border-radius: 5px;
border: 1px solid #FFD700;
background-color: #fff;
padding: 5px 5px;
font-size: 1em;
width: 78%;
outline: none;
}
.textbox{
background-color: #FFD700;
border: 1px solid #FFD700;
margin-top: 565px;
padding: 10px;
height: 50px;
width:455.5px;
float: left;
}
.t_btn{
text-decoration: none;
color:#222;
font-weight: bold;
background-color: transparent;
border: none;
font-size: 1em;
cursor: pointer;
height: 33px;
width: 70px;
outline: none;
}
.shead{
height: 50px;
width: 910px;
float: right;
margin-top: 0px;
background: #FFD700;
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
position: sticky;
border-top: #000;
}
.a1{
text-align: center;
width: 50%;
display: block;
line-height: 50px;
color: #000;
font-size: 19px;
list-style: none;
font: #000;
}
.a2{
text-align: center;
width: 50%;
display: block;
line-height: 50px;
color: #222;
float: right;
transition: background-color 0.2s ease;
font-size:19px;
text-decoration: none;
margin-top: -150px;
list-style: none;
}
.frequentmem{
display: block;
height: 100%;
width: 100%;
float: right;
}
.message-right{
margin-right:908px;
background: #fff;
height: 615px;
width:455.5px;
margin-top: 50px;
float: left;
position: fixed;
}
hr{
background: #e9e9e9;
border: 0;
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 1px;
margin: 0;
min-height: 1px;
}
.message{
width: 455.3px;
background: #fff;
height: 50px;
padding: 8px 24px;
}
float:left doesn't do anything if your position is fixed, you should add left:0 instead, on the other hand, you should always specify vertical and horizontal position of a fixed element unless you want it to stay on the part of the page it was rendered this means if your message-right are is rendered below the fold it will not be visible to your users unless you tell it at what coordinates it should remain fixed
I think floating divs and fixing the position do not go well together.
Try removing the float:left and as the user above suggested, adding the left: some_pixels, top: some_pixels to align the div "absolutely" on the page. I usually add a border/background color to divs to identify where they are on the page (then remove later), so you can try that to to make sure it is where you expect it to be.
.message-right{
margin-right:908px;
background: #fff;
height: 615px;
width:455.5px;
margin-top: 50px;
**float: left;** <-- remove
position: fixed;
left: 50px;
top: 50px;
}
With a fixed position, maybe your div is behind some other content. Have you tried using a z-index ? Setting the z-index to 1 would move it forward over another div. Also, you have no top, bottom, right or left dimensions for your fixed position. You could try moving the div around by assigning those values. Example.
Anyways, it is hard to tell what your problem is without the HTML to go with the CSS. Posting that would help you get better response.
I don't have 50 reputation, so I had to add this comment as an answer.
your code looks fine. Adding a border should do the trick.For instance:
But without the rest of the code(html and css) it would be hard to know what is wrong.
.chat-area{
margin-right:908px;
background: #fff;
border:1px solid black;<-- like this
height: 615px;
width:455.5px;
margin-top: 50px;
float: left;
position: fixed;
}

I can't get rid of the black background behind my nav links

I can't resolve this issue. I don't know how to get rid of the black behind the navs. It seems to me all the css styling is not black when I review each element.
Cheers.
Here is a screenshot of my problems.
https://drive.google.com/file/d/0B7T0xtNhpIRZYjc5VHlNVlVTdTg/view?usp=sharing
Here is the PHP/HTML
<head>
<link type="text/css" rel="stylesheet" href="Car_Style.css"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" id="font-awesome-css" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" type="text/css" media="screen">
</head>
<body>
<header id="header" class="loading";]>
<!-- Logo -->
<div id="logo">
</div>
<!-- Nav -->
<nav id="nav">
<img src="http://1673-itstudies/12-infotech/jsummers/About%20Us//About%20US/Images/LOGO_copy.png" id="logo">
<ul id="links4nav">
<li>New Vehicle</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
<a href="http://1673-itstudies/12-infotech/jsummers/Carsales_Network.php">
<h4 id="navtitle">AUTO NETWORK | THE LEAD SALE</h4>
</a>
</nav>
</header>
<div id=scroller>
<a href="#" class="back-to-top" style="display: inline;">
<i class="fa fa-arrow-circle-up"></i>
</a>
<script id="scroller">
jQuery(document).ready(function() {
var offset = 250;
var duration = 300;
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > offset) {
jQuery('.back-to-top').fadeIn(duration);
} else {
jQuery('.back-to-top').fadeOut(duration);
}
});
jQuery('.back-to-top').click(function(event) {
event.preventDefault();
jQuery('html, body').animate({scrollTop: 0}, duration);
return false;
})
});
</script>
<script id ="fading-scroller">
$(window).scroll(function() {
var pxFromBottom = 350;
if ($(window).scrollTop() + $(window).height() > $(document).height() - pxFromBottom) {
$('.scroll-btn').fadeOut('slow');
} else {
$('.scroll-btn').fadeIn('slow')
}
});
</script>
</div>
</body>
<?php
try {
# Connect to SQLite database
$dbh = new PDO("sqlite:Car_Sales_Network");
# Prepare SQL statement
$sth = $dbh->prepare('SELECT * FROM Cars_On_Network' );
# Set the Fetch Mode to Associative Array
$sth->setFetchMode(PDO::FETCH_ASSOC);
# Run the query on the database
$sth->execute();
//table printout
echo "<table>";
# Loop through returned records
while($row = $sth->fetch()) {
//print_r($row);spot
//print_r($row);
# If the image field is empty, change to dummy image
if (empty($row['car_image_url'])) {
$row['car_image_url'] = 'http://1673-itstudies/12-infotech/jsummers/Cars_Photos/placeholder.png';
}
// added these line */
echo "<table>";
/* added this line */
/* // added this line */
echo "<th>Car Make:</th>";
echo "<th>Car Model:</th>";
echo "<th>Car Badge:</th>";
echo "<th>Car Price:</th>";
echo "<th>Car Transmission:</th>";
echo "<th>P Plate Legality:</th>";
echo "<th id='car'>Car Image:</th>";
echo "<div id='1'>";
echo "<tr>";
echo "<td>". $row["car_make"] . "</td>";
echo "<td>". $row["car_model"] . "</td>";
echo "<td>". $row["car_badge"] . "</td>";
echo "<td>". $row["price"] . "</td>";
echo "<td>". $row["trans"] . "</td>";
echo "<td>". $row["P_Plate_Legal"] . "</td>";
echo "<td id='img'><img src=\"". $row["car_image_url"] . "\" /></td>";
/* // this allows the image link to be converted from a link to an image */
echo "</tr>";
echo "</div>";
//echo $row["Game_ID"];
echo "<br>";
}
echo "</table>";
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
Here is the CSS:
* {
font-family: Arial;
color: white;
transition: 1s;
background-image: url(http://1673-itstudies/12-infotech/jsummers/Cars_Photos/background.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
-webkit-text-stroke: 0.1px #333333;
}
#links4nav {
list-style-type: none;
margin: 0;
padding: 0;
font-family: Arial;
background-color: rgba(255, 255, 255, 0.9); /* Color white with alpha 0.9*/
background-color: orange;
transition: 1s;
}
#navi {
background: #ff0015;
background-color: #ff0015;
font-family: Arial;
display: inline-block;
}
table {
padding: 20px;
border: 2px;
outline: none;
background-image: none;
color: white;
}
th td {
padding-right: 20px;
padding-left: 20px;
margin-right: 5em;
}
/*********************************************************************************/
/* Header */
/*********************************************************************************/
#header {
position: fixed;
z-index: 10000;
left: 0;
top: 0;
width: 100%;
background: #ff0015;
height: 3em;
line-height: 3em;
transition: none;
padding-top: 8px;
}
body {
padding-top: 3em;
}
#logo {
position: absolute;
left: 1em;
top: 2px;
height: 3em;
line-height: 3em;
letter-spacing: -1px;
}
#logo a {
font-size: 1.25em;
}
#nav {
position: fixed;
right: 0.5em;
top: 0;
height: 3em;
line-height: 3em;
color: #ff0015;
opacity: 30;
}
#nav ul {
margin: 0;
}
#nav ul li {
display: inline-block;
margin-left: 0.5em;
font-size: 0.9em;
}
#nav ul li a {
display: block;
color: #ff0015;
text-decoration: none;
height: 3em;
line-height: 3em;
padding: 0 0.5em 0 0.5em;
outline: 0;
background-color: #ff0015;
}
/*
td{
width: 336px;
height: 223px;
}
*/
#img {
opacity: 100;
border: solid black 2px;
}
#logo {
width: 212px;
height: 48px;
position: fixed;
float: left;
}
#navtitle {
font-family: Arial;
color: white;
position: fixed;
left: 230px;
background: #ff0015;
top: -22px;
}
ul #nav #navbar{
color: #ff0015;
background-color: #ff0015;
}
#car{
width: 50px;
height: 50px;
}
}
.back-to-top {
background: none;
margin: 0;
position: fixed;
bottom: 0;
right: 1000;
width: 70px;
height: 70px;
z-index: 100;
display: none;
text-decoration: none;
color: #ffffff;
transition: 0.5s;
}
.back-to-top i {
font-size: 60px;
position: fixed;
transition: 0.5s;
}
#scroller {
background: none;
transition: 0.5s;
}
you may wanna try this:
#nav ul li {
display: inline-block;
margin-left: 0.5em;
font-size: 0.9em;
background:inherit; //Inherits its property from its parent element which in your case can be the solution
}
Try this
#nav ul li, #nav ul { background:none;}
I got your code to a fiddle but there I cant see the issue, so lets try with above.
try this
#nav ul li {
display: inline-block;
margin-left: 0.5em;
font-size: 0.9em;
background:none; //added new line.
}
Update 1:
#links4nav {
list-style-type: none;
margin: 0;
padding: 0;
font-family: Arial;
transition: 1s;
}
#nav ul li a {
display: block;
color: #fffff;
text-decoration: none;
height: 3em;
line-height: 3em;
padding: 0 0.5em 0 0.5em;
outline: 0;
}
You got lots of repeated css. avoid those. Avoid unnecessary id insertions. Map the style.css to your css for changes.
Plunker Output