Can I use input checked to initiate CSS which highlight an image? - php

I have a safety form that I'd like to highlight part of an image when an input is checked. I was able to make part of the image highlight with a hover but I can't seem to do it with CSS using Checked. Any ideas what I'm missing? If I switch the css tropic:checked to hover then it will highlight my selection. The problem is I can't get the same functionality via checked. Is it possible?
Thanks!
<style>
.check-with-label:checked ~ .product-add-image-preview {
position: absolute;
content: '';
background: rgba(0,0,0,0.5);
width: 100px;
height: 100px;
pointer-events: none;
}
.circle-with-label:checked ~ .add-head {
width: 200px;
height: 200px;
border: 1px solid #aaa; /*To show the boundaries of the element*/
}
.circle-with-label:checked ~ .add-head {
position: absolute;
content: '';
background: rgba(0,0,0,0.5);
width: 100px;
height: 100px;
pointer-events: none;
}
.trPic{
width:320px;
height:700px;
background: url(<?php echo base_url('uploads/front_body.png'); ?>) no-repeat;
border:5px solid #000000; }
.trPic .head{
position:relative;
top:10px;
left:100px;
width:60px;
height:30px;
background:#FF2400;
opacity:0; }
.trPic:checked .head {
opacity:0.7; }
</style>
<div align="center">
<?php if( !function_exists('form_open')): ?>
<?php $this->load->helper('form'); ?>
<?php endif;?>
<?php echo form_open(current_url(),array('id'=>'form')); ?>
<?php echo form_label('Head','head'); ?>
<input type="checkbox" name ="head" id="head" class="head" value="1"/>
<?php echo form_label('Face','face'); ?>
<input type="checkbox" name ="face" id="check_1" class="check-with-label" value="1" />
<?php echo form_fieldset_close(); ?>
<br />
<br />
<br />
<br />
<?php echo form_button(array('name'=>'submit','type'=>'submit','value'=>1,'content'=>'Submit')); ?>
</div>
<div class ="trPic">
<div class="head">
</div>
</div>

You could use jQuery and call addClass () adding the class that contains the styling you want on the event where the box gets checked.

Related

html and body's height is not 100%

I've tried everything I know to make the height of the black part change according to the "samples" in the picture above. Whenever I add new "sample" that will go down the black part does not follow. Is there something wrong in my code, if there is please let understand how to fix it cause Im new at this.
Here is my code:
body,
html,
.yourteachers,
.fullpage
{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.fullpage
{
background-color: black;
}
.leftForm
{
background-color: #2c384a;
width: 204px;
height: 100%;
float: left;
font-family: calibri;
color: white;
text-align: center;
}
.yourteachers
{
text-align: center;
}
.announcementSlider
{
background-color: #323f4f;
color: white;
font-size: 24px;
height: 280px;
width: 200px;
margin: 20px;
display: inline-block;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/teachers.css">
</head>
<body>
<header>
<nav>
<div class="nav-wrapper blue">
<div class="container">
Teachers
<i class="material-icons">menu</i>
<ul class="hide-on-med-and-down right">
<li><a id="dashb">Home</a></li>
<li><a id="logout">Log Out</a></li>
</ul>
</div>
</div>
</nav>
</header>
<div class="fullpage">
<div class="leftForm hide-on-med-and-down">
<img src="pictures/default-avatar-250x250.png">
<p class="name">
<?php echo $name; ?>
</p>
<p class="section">
<?php echo $grade; ?>-
<?php echo $section; ?>
</p>
</div>
<div class="leftForm sidenav blue center" id="slide_out">
<img src="pictures/default-avatar-250x250.png">
<p class="name">
<?php echo $name; ?>
</p>
<p class="section">
<?php echo $grade; ?>-
<?php echo $section; ?>
</p>
</div>
<div class="yourteachers">
<?php
while ($row = mysqli_fetch_array($query)) {
echo '<a class="announcementSlider" href="teacherinfo.php?id=' . $row['IDNum'] . '">
<img src="pictures/blank photo.png" class="teacherpic"><br>
<span>'.$row['LastName'].'</span><br>
<span>'.$row['Grade'].' - </span>
<span>'.$row['Section'].'</span>
</a>';
}
?>
</div>
</div>
<script type="text/javascript">
var a = document.getElementsByClassName("announcementSlider");
for (i = 0; i < a.length; i++) {
a[i].onclick = function() {
location.href = "teacherinfo.php";
};
}
</script>
<script src="js/teachers.js"></script>
<script src="sameFunctions.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript">
const slide_menu = document.querySelectorAll(".sidenav");
M.Sidenav.init(slide_menu, {});
</script>
<footer>
<div class="foot">
<div class="socialMed">
</div>
</div>
</footer>
</body>
</html>
It's because your .fullpage needs to follow .yourteachers 's height. And your .leftForm has float: left but it's parent (.fullpage) still doesn't know the exact height of it's children. To fix it, you need to add clear: both by using div with additional .clearboth class or css :before or :after pseudo-selector.
see my fiddle here
In my approach above, I'm using fixed sidebar and add margin-left on .yourteachers to fix sidebar height issue. For better implementation, I recommend you to use flex box so you keep your sidebar not using fixed position.
<!-- language-all: lang-css -->
body, html, .yourteachers, .fullpage {
margin: 0;
padding: 0;
}
body, html {
width: 100%;
height: 100%;
background: black;
}
.fullpage {
overflow: hidden
}
.leftForm{
background-color: #2c384a;
width: 204px;
height: 100%;
float: left;
font-family: calibri;
color: white;
text-align: center;
}
.yourteachers{
text-align: center;
}
.announcementSlider{
background-color: #323f4f;
color: white;
font-size: 24px;
height: 280px;
width: 200px;
margin: 20px;
display: inline-block;
}
Have u tried height: 100vh? Height is automatically adjusting, so just height: 100% means 100% height of parent.

How to position radiobutton under div?

I am newbie in HTML and CSS. I need radiobutton which locates under div. Now there's a div and radiobutton to right of.
<div class="rates">
<? foreach ($rates as $rate) { ?>
<div class="rates-block" <? if ($rate->id % 4 != 1) { ?> style="margin-left: 48px;" <? } ?>>
<img src="/images/aukc_image/<?= $rate->img ?>" class="products-img rate-img" alt="product-1">
</div>
<input class="rate-radio" type="radio" name="radio1" value="<?= $rate->count ?>;<?= $rate->price ?>">
<? } ?>
</div>
There's my CSS for thats classes:
.rates {
margin-top: 19px;
}
.rates-block {
display: inline-block;
background-color: #FFFFFF;
width: 152px;
height: 154px;
border: 1px solid rgb(220, 220, 220);
margin-left: 101px;
}
.rate-radio {
display: inline-block;
}
Now I have this
But I need something like this
Try this:
.rates {
margin-top: 19px;
}
.product-wrapper{
display: inline-block;
background-color: #FFFFFF;
width: 152px;
margin-left: 50px;
}
.rates-block {
width: 100%;
height: 154px;
border: 1px solid rgb(220, 220, 220);
}
.rate-radio {
display: inline-block;
}
<div class="rates">
<div class="product-wrapper">
<div class="rates-block">
<img src="http://www.creativeprintpack.com/images/shoppingbag4.jpg" class="products-img rate-img" alt="product-1" style="width:100%">
</div>
<input class="rate-radio" type="radio" name="radio1" value="wewe">Rate 0</input>
</div>
<div class="product-wrapper">
<div class="rates-block">
<img src="http://www.creativeprintpack.com/images/shoppingbag4.jpg" class="products-img rate-img" alt="product-1" style="width:100%">
</div>
<input class="rate-radio" type="radio" name="radio1" value="wewe">Rate 1</input>
</div>
</div>
I have added a wrapper for each product/rate, which has the width set, the div containing the image is 100% width as the input aswell

How to center my page content when browser window is in full screen, and extend my footer across the entire page?

Please take a look at this site
Mess around with the browser window size for a little bit (I'm on Chrome and have not tried it with other browsers) and you will notice that my website takes up the entire page when the browser window is taking up only half of the monitor, but when the browser is in full screen mode, the content of the website stays to the left side of the webpage and the white margins get bigger. Also, my footer doesn't take up the entire page.
I don't want the site design to change, I just want all my site content to be shifted to the middle of the page when in full screen mode. I also want my footer rather then to be just sitting at the bottom of page only taking up part of it, extending across the entire page
HTML Code
<html !DOCTYPE>
<head>
<title>Mathew Crogan's Website</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>
<form action="form.php" method="POST" id="form">
<br>
<br>
<br>Name:
<br>
<input name="contact_name" type="text">
<br>
<br>Email address:
<br>
<input type="text" name="contact_email">
<br>
<br>Message:
<br>
<textarea name="contact_text" rows="6" cols="30"></textarea>
<br>
<br>
<input type="Submit" value="Send">
</form>
<div style="height:60px; background-color:#000; color:#FFF; position:absolute; margin-left:0px; margin-top:200px;width:275px; text-align:center;">
<h3>Contact Me!</h3>
</div>
<div id="header">
<h1>Welcome To My Website!</h1>
</div>
<div id="firstlink"> <a id="firstlink" href="form.php">Main</a>
</div>
<div id="secondlink"> <a id="secondlink" href="me.php">Who I Am</a>
</div>
<div id="rollover"> <a id="rollover" href="project.php">Projects</a>
<a id="rollover" href="code.php">Code Used For These Pages</a>
</div>
<br>
<br>
<br>
<div id="condiv">
<p id="content">This is a website where I, Mathew Crogan, test out <i>HTML</i> or <i>PHP</i> or <i>CSS</i> Coding</p>
</div>
<div id="image">
<img id="me" src="img/1235154_462876267144148_1500701414_n.jpg">
</div>
<div id="footer">Web Designer: Mathew Crogan
<br>You are allowed to use this code. You can copy it from the "Code Used From These Pages" section. In order to use this code however, you must <b>GIVE CREDIT TO MATHEW CROGAN AND ASK FOR HIS PERMISSION USING THE "Contact Me" SECTION OF HIS MAIN PAGE</b>
</div>
</body>
</html>
Style.css:
html {
height:500px;
width:1000px;
;
}
#header {
height: 75px;
width: 600px;
margin-left:25px;
background-color: #DDDDDD;
text-align: center;
font-family: Tahoma, Geneva, sans-serif;
float:left;
}
#form {
float:left;
border: 1px solid #000000;
padding: 5px 5px 5px 5px;
margin-top: 200px;
}
#content {
color:red;
}
#condiv {
height:320px;
width:420px;
margin-left:315px;
margin-top:160px;
border: 1px solid #000;
border-radius:25px;
padding:10px 10px 10px 10px;
}
#image {
height:350px;
width:300px;
position:relative;
left:800px;
bottom:380px;
}
#me {
border:2px solid #000;
border-radius:25px;
}
#secondlink {
margin-left:190px;
}
a#rollover:link, a#rollover:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
border:1px solid #000;
float:left;
margin-top:30px;
height:40px;
padding-top:8px;
}
a#rollover:hover, a#rollover:active {
background-color:#A7A7A7;
}
a#firstlink:link, a#firstlink:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
height:44px;
padding-top:8px;
text-decoration:none;
border:1px solid #000;
position:absolute;
margin-top:105px;
margin-left:343px;
}
a#firstlink:hover, a#firstlink:active {
background-color:#A7A7A7;
}
a#secondlink:link, a#secondlink:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
border:1px solid #000;
margin-top:30px;
float:left;
height:40px;
padding-top:8px;
}
a#secondlink:hover, a#secondlink:active {
background-color:#A7A7A7;
}
#footer {
display:block;
text-align:center;
border:1px solid #000;
background-color:#B5B5B5;
width:1000px;
position:absolute height:100px;
float:left;
padding:5px 20px 5px 20px;
margin-top:400px;
}
You can centre the whole body so you can have the space on both sides:
html {
height:500px;
width:1000px;
margin: 0 auto;
}
This is the most common method to center block elements in css, as explained in the link. However, I'd change it to something even more common:
html {
width: 100%:
}
body {
height:500px;
width:960px;
margin: 0 auto;
}
In this way, you can be assured that the html is the "base" for your meassures, and it's the full width of the page. Then you can work with the body. Also I set it a little smaller, to 960px, because one of the common resolutions is 1024px wide and with the scrollbars and other things it gets to just above that measure.
Lastly, the footer is a story apart that needs a huge article. And other people has already done it, it's called sticky footer, and google will provide enough information:
http://css-tricks.com/snippets/css/sticky-footer/

How to overlay an image on other one with transperent effect using HTML-CSS

I want to overlay one image on other using CSS-PHP. Please see the below HTML and CSS snippet and give ur wise suggestions:
The images are present in header part of the division:
j_logo.jpg and MMPHero3.jpg. Of which former should be transparent and in left container while later one should occupy entire header region.
<body>
<div id="container">
<div id="header">
<div id="header-left-container">
<img src="j_logo.jpg" alt="jubilant"/>
</div>
<div id="header-right-container">
<img src="MMPHero3.jpg" alt="drug"/>
</div>
</div>
<div id="content"> Sidebar <p> </p>
<div class="form">
<p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<p>Enter Drug Name </p>
<input type="text" name="drugName" value="<?php echo (isset($_POST['drugName']) ? $_POST['drugName'] : '') ?>">
<!--To retain search query after click added value="<?php echo (isset($_POST['drugName']) ? $_POST['drugName'] : '') ?>*/-->
<!-- This is commenting style in HTML -->
<p><input type="submit" value="search"></p>
</form>
</div>
</div>
<div id="sidebar"> Body
</div>
<div id="footer"> </div>
</body>
</html>
CSS style-sheet is below:
body {background: #ffffff;}
a {color: #2b2bf6;}
h1 {font-size: 30px;}
#container
{width:1000px;
margin: 0 auto;
background: #dddddd;}
#header
{height: 150px;
margin: 0px;
padding: 0px;
background: #FFFFA3;}
#header-right-container img
{border:none;
width:80%;
height:150px;
float: right;}
#header-left-container
{width:20%;
float: left}
#header-left-container img
{border:none;
width:100%;
height:150px auto;
float: left;}
#sidebar
{
position:relative;
width: 80%;
height: 400px;
float:right;
background: #FFFFA3; ;}
#content
{
position:relative;
width: 20%;
height: 400px;
float: left;
background: #f0e811;;}
#footer
{width: 100%;
height: 70px;
float: left;
background: #000000;
div.result
{
width:88%;
padding:5%;
border:5px solid gray;
margin:5px;
align:center;
}
div.form
{
width:180px;
padding:5%;
border:5px solid gray;
margin:50px;
align:center;
float:right;
}
table, td, th
{
border:0.5px solid blue;
align:center
}
th
{
background-color:#3886FC;
color:white;
}
I believe you should set the style to be something like "position:absolute; left:100px; top:100px; opacity:0.3;" for the image element on top.
Use style="opacity:0.5;" where opacity can be any val from 0.1 to 1
and for overlapping the img onto another you need to specify style="z-index:1;", the higher the z-index more priority will be given to it.

One scroll bar for 2 separate divs

I have two DIV's that are side by side. One div is my side bar (Left Of Screen), the other div is my main content (Right Of Screen).
What I'm looking for:
What I want is one visable scroll bar to the far right of the screen. I would like that scrol bar to scroll both left and right div's.
My Problem:
Currently my left sidebar has a tree menu. When I expand my tree menu, I have no scroll bar to scroll down through the side bar content that was expanded. I'm able to add a scroll bar to my side bar, but that looks very ugly. I just want 1 scroll bar on the far right that handles both div's.
Can someone help me on this one?
My index.php file
<?php
include 'sidebar.php';
include 'main_body.php';
?>
My sidebar.php
<?php
echo '<link rel="stylesheet" href="css/style.css" type="text/css">';
echo '<script type="text/javascript" src="js/jquery1_3_2.js"></script>';
include 'function/functions.php';
// Establish a connection to our database
db_connect();
echo'
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function()
{
jQuery(this).next(".content").slideToggle(500);
});
});
</script>
';
echo'<div class="sidebar">';
// Side Bar Start
echo '
<img src="images/hdc_logo.png">
<br>
<br>
<p class="heading"><strong>CUSTOMER</strong></p>
<div class="content">';
//Display all customers from database
query_all_customers();
echo '</div>
<p class="heading"><strong>CABINET</strong></p>
<div class="content">';
// Display all cabinets from database
query_all_cabinets();
echo'</div>
</div>';
?>
My main content area
<?php
ini_set('display_errors', 1);
echo '<div class="main">';
echo'
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here';
?>
My .css file
.sidebar {
width:200px;
position:fixed;
top:0px;
left:0px;
height:100%;
background-color:#54524F;
/*overflow-y: scroll;*/
}
.main {
width: auto;
margin-left: 200px;
}
.heading {
margin: 1px;
color: #fff;
padding: 3px 10px;
cursor: pointer;
position: relative;
background-color:#000000;
}
.content {
padding: 5px 10px;
}
#submit {
width:185px;
background-color: black;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #fff;
font-family:'Oswald';
font-size: 16px;
text-decoration: none;
cursor: pointer;
border:none;
}
#submit:hover {
border: none;
background:#FF9933;
box-shadow: 0px 0px 1px #777;
}
tr:nth-of-type(odd) {
background-color:#D4D4D4;
}
.container0 {
height: 100%;
width: 100%;
overflow-x: hidden;
position: relative;
padding-bottom: 30px;
background-color:black;
}
JSFiddle
in your css, set position of the sidebar to relative and set float to left, like this:
.sidebar {
width:200px;
position:relative;
top:0px;
left:0px;
height:100%;
background-color:#54524F;
float:left
}
the updated version of your jsfiddle to show you that it works :) http://jsfiddle.net/BrJDE/3/
because you dont want to have the scrollbar at the side of the page, i made some more examples for you. tell me if they are what you want, if its not, i would love to help you again.
both of these examples use 2 additional divs compared to the content you provided. these will make that you can position the scrollbar inside those div's instead of at the side of the browser. if you need me to explain the changes i made, just tell me.
scrollbar inside the page:
http://jsfiddle.net/BrJDE/6/
scrollbar inside the page at the left side of the scrolling div:
http://jsfiddle.net/BrJDE/5/

Categories