How to define font-size different divs - html

In my project, I have three divs.
"upBtDiv and ulfDiv" are in attFile div.
The font-size in upBtDiv is 16px, and it works successfully.But the font-size of 10px in ulfDiv works fail.The font-size in ulfDiv is remain 16px.
When i define .attFile{margin-left:15%;margin-top:5%;font-szie:10px}, and it works fine.But the font-size of "upBtDiv and ulfDiv" are both 10px.
Here is my css code:
.attFile {
margin-left:15%;
margin-top:5%
}
.upBtDiv {
position:relative;
overflow:hidden;
display:inline-block;
display:inline;font-size:16px
}
.upBtDiv label { cursor:pointer }
.upBtDiv input {
position:absolute;
top:0;
right:0;
margin:0;
border:solid transparent;
opacity: 0;
filter:alpha(opacity=0);
cursor:pointer;
width:66%
}
.ulfDiv {
height:10px;
line-height:22px;
margin:10px 0;
font-size:10px
}
.ulfDiv .delimg,
.dwlimg {
color:#090;
cursor:pointer;
display:none
}
.ulfDiv:hover .delimg {
display: inline-block;
}
.ulfDiv:hover .dwlimg {
display: inline-block;
}
.delimg:hover { color:blue; }
.dwlimg:hover { color:blue; }
<div class="attFile" id="attFileId">
<div class="upBtDiv">
<label style="color:green">attfile:</label>
<input type="file" id="fulId" name="mypic">
</div>
<div class="ulfDiv" id="ulfId1">
<b class='dataname'>30k</b>
<span class='delimg' rel='" + data.pic + "'>delete</span>
<a class='dwlimg' href='files/" + data.pic + "' target='_blank'>add</a>
</div>
</div>
It seems nothing wrong in my code.I suppose the overflow:hidden attribute of upBtDiv is the reason.But i have no idea about it. Who can help me ?

.attFile > .upBtDiv{
font-size: 28px;
}
.attFile > .ulfDiv{
font-size: 23px;
}
<div class="attFile" id="attFileId">
<div class="upBtDiv" >
<label style="color:green">attfile:</label> <input type="file" id="fulId" name="mypic">
</div>
<div class="ulfDiv" id="ulfId1">
<b class='dataname' >30k</b>
<span class='delimg' rel='"+data.pic+"'>delete</span>
<a class='dwlimg' href='files/"+data.pic+"' target='_blank'>add</a>
</div>
</div>

Related

Understanding how label works when elements hidden

I am trying to understand, how a can label work in conjunction with elements states like input[type="type=""]:checked or input[type=""]:unchecked.I got a very basic example which I am trying to work out, but I cannot make the label a circle or square that can have a check mark or unchecked when clicked. What makes the label have that outlook and showing checked and unchecked state? Does the label need to have a width and height? If so do I need to make it a block level element.
input[type="checkbox"]{
width:0;
heigh:0;
/* or display:none? */
}
label{
position:relative;
width: 20px;
height: 20px;
cursor: pointer;
}
label:before,
label:after{
font-size:50px;
}
label:before{
content: '\f096'; /
//Can be some good example
}
label:after{
content: '\f00c';
//Can be some good example
}
input[type="checkbox"]:checked{
content:"check"
//Can be some good example
}
input[type="checkbox"]:unchecked{
content:"x"
//Can be some good example
}
Something achievable like this but without text next to labels as I want checkbox based on styling.
you need to make a relationship ( css wise ) between your checkbox and the clicked label and change it's content . use css selectors for that. for example + or ~
in the example below i used :before and :after . :after will appear only when the checkbox is :checked. i think this is what you want.
IMPORTANT ! : you set the same id to all checkboxes this is bad because
duplicate ID's are not a good practice when writing HTML
you link all labels to the same checkbox ( all are linked to the checkbox with id checkbox . in the below example all have different ids and so every label is linked with it's corresponding checkbox
see code below
.img-holder{
position:relative
}
.checkbox-holder{
position:absolute;
background: #fcfff4;
margin-top:5px;
margin-left:10px;
width:50px;
}
input[type="checkbox"]{
width:0;
height:0;
}
label{
position:relative;
width: 20px;
height: 20px;
cursor: pointer;
}
label:before,
label:after{
font-size:50px;
}
label:before{
border:2px solid red;
content:"";
height:20px;
width:20px;
border-radius:100%;
display:inline-block;
}
label:after {
content:'';
position:absolute;
width:10px;
height:10px;
border-radius:100%;
background:green;
top:-2px;
left:7px;
opacity:0;
}
input[type="checkbox"]:checked + label:after {
opacity:1;
}
input[type="checkbox"]:checked + label:before {
border-color:green;
}
<div class="container">
<div class="row">
<div class="col-3 img-holder">
<div class="checkbox-holder">
<input type="checkbox" id="checkbox">
<label for="checkbox">
</div>
<img src="https://placeimg.com/300/480/any/grayscale" alt="">
<!-- <div class="flex-column justify-content-center">
<h4 class="add">Added</h4>
<h4 class="remove">Removed</h4>
</div> -->
</div>
<div class="col-3 img-holder">
<div class="checkbox-holder">
<input type="checkbox" id="checkbox2">
<label for="checkbox2">
</div>
<img src="https://placeimg.com/300/480/any/sephia" alt="">
<!-- <div class="flex-column justify-content-center">
<h4 class="add">Added</h4>
<h4 class="remove">Removed</h4>
</div> -->
</div>
<div class="col-3 img-holder">
<div class="checkbox-holder">
<input type="checkbox" id="checkbox3">
<label for="checkbox3">
</div>
<img src="https://placeimg.com/300/480/nature/grayscale" alt="">
<!-- <div class="flex-column justify-content-center">
<h4 class="add">Added</h4>
<h4 class="remove">Removed</h4>
</div> -->
</div>
<div class="col-3 img-holder">
<div class="checkbox-holder">
<input type="checkbox" id="checkbox4">
<label for="checkbox4">
</div>
<img src="https://placeimg.com/300/480/arch/grayscale" alt="">
<!-- <div class="flex-column justify-content-center">
<h4 class="add">Added</h4>
<h4 class="remove">Removed</h4>
</div> -->
</div>
</div>
</div>
You cannot change the content the label itself, but you can control the content of the pseudo element after and before. You can add the logic of square/circle with something that can represent check and uncheck.
input[type='checkbox'] {
width: 0;
height: 0;
}
input[type='checkbox']:checked + label:after {
content: "checked";
}
Demo
To answer your question in the comment
How they make funky circle buttons and put a checkbox inside it when one clicks?
You can use CSS animations. The label will already have the check symbol in it but won't have shown in the unchecked state of the input box. And when the element is checked, it will change the opacity to 1, showing the checkbox in an animated way.
input[type='checkbox'] {
width: 0;
height: 0;
}
input[type='checkbox'] + label:after {
content: "checked";
opacity: 0;
-webkit-transition: all 0.50s;
-moz-transition: all 0.50s;
-o-transition: all 0.50s;
transition: all 0.50s;
}
input[type='checkbox']:checked + label:after {
opacity: 1;
}
Demo
If you want a custom look and behavior for your checkboxes, you'll have to use some trickery. This involves using CSS to hide your checkboxes and draw a stylable box instead + a ✔ character when your checkbox is selected.
Here's a pretty basic example :
var items = document.getElementsByClassName("item");
for (var i=0; i < items.length; i++) {
items[i].addEventListener("click", function(){
var checkbox = this.querySelector("input[type='checkbox']");
checkbox.checked = checkbox.checked ? false : true;
this.classList.toggle("selected", checkbox.checked);
});
}
.item {
padding: 5px 30px 5px 30px;
display: block;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
.item:hover {
cursor: pointer;
}
.checker {
border-color: #333;
position: absolute;
background: #fff;
width:14px;
height:14px;
border: 2px solid #999;
left: 10px;
z-index: -5;
display: block;
}
.selected .checker {
border-color: #2199cb;
}
.checker input {
height: 18px;
width: 18px;
opacity: 0;
border: none;
background: none;
}
.selected .checker:after {
color: #ef8730;
width: 16px;
z-index: 99;
font-size: 28px;
margin-top: -40px;
float: right;
content: "\2714";
}
<div class="item">
<label class="checker">
<input type="checkbox">
</label>
Item 1
</div>
<div class="item selected">
<label class="checker">
<input type="checkbox" checked>
</label>
Item 2
</div>
<div class="item">
<label class="checker">
<input type="checkbox">
</label>
Item 3
</div>
See also this JSFiddle demo

Why is border radius not showing up in IE?

How do I get border radius to work in IE?
I have an <input type=image> element in my html. In my css I have border-top-right-radius:12px; and border-bottom-right-radius:12px.
Everything works in Chrome and Firefox, but in IE11, the image shows up with square corners instead of rounded corners.
I also have this meta tag in my html:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
The code is below.
CSS:
body .overlay {
background-color: rgba(0, 114, 198,.7);
height:100%;
position:relative;
}
body .layer {
background: url('photo-homebanner.jpg') 55%;
position:relative;
top:0;
left:0;
width:100%;
height:100%;
}
body .goldenDiv {
width:665px;
height:326px;
position:fixed;
z-index:100;
margin-top:-38px;
margin-left:-8px;
}
body h1 {
color:white;
text-align:center;
font-family:sans-serif;
padding-top:22px;
padding-bottom:5px;
font-size:45px;
}
body h3 {
color:white;
text-align:center;
font-family:sans-serif;
font-weight:100;
padding-bottom:14px;
}
body h3.hidden {
visibility:hidden;
padding-bottom:0px;
position:absolute;
top:220px;
left:190px;
}
body input:focus {
outline:none;
}
body .prettyInput {
align-content: center;
padding-left: 20px;
padding-right: 70px;
margin-left: 106px;
width: 350px;
height: 61px;
font-size: 18px;
font-weight: 600;
border-radius: 15px;
border: hidden;
margin-bottom: 40px;
}
body .inputOverlap {
position:absolute;
top:167px;
top:166px\9;
left:485px;
z-index:3;
border-top-right-radius:12px;
border-bottom-right-radius:12px;
}
body hr {
color:white;
position:absolute;
top: 77px;
left:120px;
align-content:center;
}
#-moz-document url-prefix() {
body .inputOverlap {
position:absolute;
top:168px;
left:485px;
z-index:3;
border-top-right-radius:12px;
border-bottom-right-radius:12px;
}
}
HTML:
<body>
<div class="goldenDiv">
<div class="layer">
<div class="overlay">
<h1>Stay ahead of industry news!</h1>
<hr width="450px"/>
<h3>Let us send you the latest from our Marketing Department.</h3>
<input id="emailAddress" type="text" class="prettyInput" required placeholder="Your email address here" />
<input onclick="sendEmail()" type="image" width="57px" height="57px" class="inputOverlap" src="submitButton.jpg" />
<h3 class="hidden" id="hiddenValidation">*Please enter a valid email address.</h3>
<h3>100% privacy, no spam, just news.</h3>
</div>
</div>
</div>
</body>
The issue seems to be with IE's rendering of input[type="image"]- if you give it a border attribute you can see that the image is rendered ignoring the border-radius property.
Easiest way to fix would be to wrap the input[type="image"] in a div, apply the positioning, border, and sizing properties to the div (apply sizing to the input[type="image"] as well), and tag the div with overflow:hidden;.
Stylistic notes (unrelated to the problem):
border-radius: 0 12px 12px 0; means the same thing as
border-top-right-radius:12px;
border-bottom-right-radius:12px;
but is less than half the locs. I suggest only using the verbose versions if you need to adjust only one corner and want whatever the others were set to to be preserved.
The height and width attributes on your image should be set in the CSS not on the input[type="image"]. Those attributes have been frowned upon for a very long time, especially since the CSS ones accomplish the same thing.

How to display a button over a picture only when hovering it?

I'm trying to reproduce some pieces of CSS from the http://flink.to website, especially the tiles which contains for each article the picture, the title, the author, the link to the author page and the link to the article.
Here is the HTML for one tile :
<div class="block-module">
<a href="http://flink.to/stories/54b6e61de3039db33f00000b" class="article-link">
<span class="button">View Story</span>
</a>
<img src="https://cdn01.flink.to/api/image/54f492ec30323921c9000000/300/300/fill">
<div class="block-about">
<h2 class="block-title">Arch Enemy’s Perpetual Revolution</h2>
<span class="block-stats">
by Andrew Epstein
</span>
</div>
</div>
Here is the CSS for one tile :
.block-module { width: 283px; height: 283px; font-size: 0.9622em; display: block; cursor:pointer; border-radius:0.3125em; overflow:hidden; z-index:4; position:relative; }
.block-about { position:absolute; bottom:0; left:0; right:0; padding:4em 1em 1em 1em; background-image:-webkit-linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); background-image:linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); }
.block-about a { position:relative; z-index:5; }
.block-title { max-width:100%; margin:0 0 0; color: white !important;font-size:1.625em; }
.block-stats { width:100%; margin-top:0.35714em; font-size:0.875em; color:rgba(255,255,255,0.55) !important; }
.button { color:#ffffff; background-color:#337d94; }
.author-link { color:#659dae; }
Everything's OK except that we can't access the article and the "view story" link which is supposed to show up only when we hover the picture, in the middle/center of it.
Edit : Here is a demo : http://jsfiddle.net/5qwejk20/
As the website's CSS sheet of Flink.to is really very complicated, I didn't find how to resolve this. Could you please help me ?
There is a lot of CSS, and obviously it's hard to tell what does what and it will need to be trimmed. But from what I can tell these are the styles making it happen. The button opacity is initially 0 (hidden), so needed to change to 1.
JSFiddle
I added this style to make it show with the cursor
.view-full-module.mod-custom-icon:hover .button.view-full-custom-el {
opacity: 1;
}
By looking at the css the elements are hiding and showing by using the z-index property and CSS Positioning. Try the following code, I use different values of z-index to overlap elements. Remember that the z-index property only is valid for elements with position:absolute,position:relative or position:fixed so you have to scaffold your website having this on mind. I also added an id to the img to select it on the css. http://jsfiddle.net/cfahhmkj/
HTML
<div class="block-module">
<a href="http://flink.to/stories/54b6e61de3039db33f00000b" class="article-link">
<span class="button">View Story</span>
</a>
<img class="albumImage" src="https://cdn01.flink.to/api/image/54f492ec30323921c9000000/300/300/fill">
<div class="block-about" >
<h2 class="block-title">Arch Enemy’s Perpetual Revolution</h2>
<span class="block-stats">
by Andrew Epstein
</span>
</div>
</div>
CSS
.block-module { width: 283px; height: 283px; font-size: 0.9622em; display: block; cursor:pointer; border-radius:0.3125em; overflow:hidden; z-index:4; position:relative; }
.block-about { position:absolute; bottom:0; left:0; right:0; padding:4em 1em 1em 1em; background-image:-webkit-linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); background-image:linear-gradient(transparent, rgba(0,0,0,0.55), rgba(0,0,0,0.8)); }
.block-about a { position:relative; z-index:5; }
.block-title { max-width:100%; margin:0 0 0; color: white !important;font-size:1.625em; }
.block-stats { width:100%; margin-top:0.35714em; font-size:0.875em; color:rgba(255,255,255,0.55) !important; }
.button { color:#ffffff; background-color:#337d94; }
.author-link { color:#659dae; }
.article-link {
position:absolute;
left:110px;
top: 120px;
z-index:-1;
}
.albumImage{
position:absolute;
z-index:0;
}
.albumImage:hover{
z-index:-2;
}

Getting an image placed below a button

I have been working with several solutions on the web and have not found anything that works.
I am trying to do something that should be simple. I am trying to have an image of a "button" underneath an actual button. When I do this, the image always overlaps the button itself.
HTML:
<div id="button"> <!-- Container for my image and button -->
<img src="C:\Users\Hansen\Desktop\Websigte\Images\buttonUnclicked.png" />
<input type="button" value="Roofing" onclick="createImageRoof();" style="position: absolute"/>
</div>
CSS:
#button {
height:30px;
padding:3px;
position:relative;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
Instead of using an actual image (which you won't be able to put behind anything), just make it a background image.
CSS:
#button {
height:30px;
padding:3px;
position:relative;
background: url('file:///C:/Users/Hansen/Desktop/Websigte/Images/buttonUnclicked.png');
background-repeat: no-repeat;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
jsBin demo
Use a background image for #button if you want
<div id="button">
<input type="button" value="Roofing"/>
</div>
CSS:
#button {
width:90px;
height:30px;
padding:3px;
position:relative;
background: url(Images\buttonUnclicked.png);
}
#button > input {
position:absolute;
left:5px;
top:6px;
width: 86px;
}
If you adjust the number for the left and the top in the CSS, you can move your picture around. I called the picture #myImage in the HTML. Hope that helps.
CSS
#myImage{
position:absolute;
left:10px;
top:50px;
}
#button {
height:30px;
padding:3px;
position:relative;
}
input[type=button] {
font: 12px verdana,arial,sans-serif;
width: 86px;
float:left;
z-index:0;
}
html
<div id="button"> <!-- Container for my image and button -->
<img id="myImage" src="C:\Users\Hansen\Desktop\Websigte\Images\buttonUnclicked.png" />
<input type="button" value="Roofing" onclick="createImageRoof();" style="position: absolute"/>
</div>

DIV expanding over the DIV below

I just hit sth that appears to be a bug or at least a really weird feature of CSS/HTML.
Now, the problem is that i got three divs in a row, all inside a parent div.
The first and the second one are supposed to be text containers in a chat-like matter. The last one is supposed to be excluded and be a paging navigation.
On the very first page, that works fine. On every other page, the last text container div expands over the navigation. When using the Chrome developer tools, it shows me that the second div is only having its real size, while the background still expands over the navigation. But if i delete the navigation, the second text container resizes to its real size.
Also, when using
position:absolute;
it doesn't expand. Setting the position to relative explicitly didn't fix the problem and setting the background-color to sth else didn't change the white background.
I made you a quick demonstration under jsfiddle.net.
So the final question is: Why does the second text div expand? Or doesn't it but it looks like it does?
//edit: As suggested in the comments, here is the raw CSS/HTML outside jsfiddle. I still don't think that's a good idea, but if you say so..
<div class="decoded_chat" pagenr="1" style="display: block;">
<div class="decoded_user decoded_user_first" isme="0">
<a href="https://www.facebook.com/4" target="_new" title="Profil aufrufen">
<img class="decoded_user_avatar" src="http://graph.facebook.com/4/picture?type=square">
<div class="decoded_user_name">
Zuckerberg
</div>
</a>
<div class="decoded_msg_date">
02.02.2014, 01:36 Uhr
</div>
<div class="decoded_msg">
I will listen to the songs when I'm not so tired
</div>
<div class="decoded_msg">
I don't know.. Possibly
</div>
<div class="decoded_user decoded_user_last" isme="0">
<a href="https://www.facebook.com/4" target="_new" title="Profil aufrufen">
<img class="decoded_user_avatar" src="http://graph.facebook.com/4/picture?type=square">
<div class="decoded_user_name">
Zuckerberg
</div>
</a>
<div class="decoded_msg_date">
02.02.2014, 01:33 Uhr
</div>
<div class="decoded_msg">
I've been ill all week.. Just haven't had time for much
</div>
<div class="decoded_chat_pager">
<a href="javascript:void(0);" pagenr="0" class="cloudview_msg_prev">
« Vorherige Seite
</a>
<a href="javascript:void(0);" pagenr="2" class="cloudview_msg_next">
Nächste Seite »
</a>
</div>
</div>
a {
text-decoration: none;
color: white;
}
.chat_list {
width:100%;
}
.decoded_chat {
text-align:left;
width:100%;
margin:auto;
background-color:white;
color:black;
border-radius:10px;
}
.cloudview_msg_next {
float:right;
}
.decoded_chat_pager {
margin:auto;
margin-top:5px;
text-align:left;
width:95%;
}
.decoded_msg {
margin-bottom:3px;
}
.decoded_user {
padding:15px 10px;
min-height:50px;
}
.decoded_user_last {
border-bottom-left-radius:10px;
border-bottom-right-radius:10px;
}
.decoded_user_first {
border-top-left-radius:10px;
border-top-right-radius:10px;
}
.decoded_user_name {
color:black;
margin-bottom:5px;
}
.mychatmessage {
background-color:#BFF2BF;
}
.decoded_msg_date {
float:right;
color:grey;
margin-top:-30px;
}
.decoded_user_avatar {
position:absolute;
}
.decoded_user_name {
font-weight:bold;
}
.decoded_user_name, .decoded_msg {
margin-left:64px;
}
table {
text-align:center;
}
.flipped-180 {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter:"FlipH";
}
#detailopener, #return_to_msg, #return_to_cloud, #cloudview_delete {
display:none;
}
.chat_list_names {
color:grey;
}
.invi {
position:fixed;
width:1px;
height:1px;
top:-2000px;
left:-2000px;
}
.next_page_chat_list {
text-align:right;
padding-right:5px;
}
.last_page_chat_list {
padding-left:5px;
text-align:left;
}
.loadingtext {
margin-top:7px;
}
#opener {
position:fixed;
left:25px;
bottom:25px;
cursor:pointer;
display:none;
}
.dontdroponme {
opacity:0.3;
}
#dropper {
position:fixed;
right:25px;
bottom:25px;
cursor:pointer;
display:none;
}
.dropinfo {
border-radius:7px;
color:white;
padding:5px 25px;
}
.dorpinfo img {
width:48px;
}
.chatlist_button img, .decoded_user_avatar {
box-shadow:0 0 5px #888;
border-radius:5px;
}
.chatlist_button {
background-color:white;
border-radius:5px;
box-shadow:0 0 5px #888;
padding:5px;
cursor:move;
max-width:200px;
margin:auto;
}
.ui-draggable-dragging {
position:absolute;
z-index:5;
}
body {
height:100%;
margin:0;
background-color:#3B5998;
color:white;
font-size:12px;
font-family:Calibri;
}
#innerbody {
margin:auto;
width:55%;
text-align:center;
}
#innerbody_floater {
height:50%;
width:100%;
margin:0;
}
Copy from http://www.w3schools.com/css/css_positioning.asp
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is html: