css place the items in div class - html

I want:
block
block1 block2 block2
where
block ="head"
block1="h1"
block2="search box"
block3="itembox"
I want to put them in side by side..
I have tried below code in jsfiddle:
jsfiddle
but here these blocks not coming in same line.

don't use head tag use header for that
try this
#search {
display: inline-block;
}
http://jsfiddle.net/dm8044a8/2/

The element can include a title for the document, scripts, styles, meta information, and more.Head is not used inside inside BODY.
Use header instead tag.
I don't understand <itembox> tag. Are u using any framework?. I think you want some thing like this. Please change the width value as per your requirement.
header {
background: #fff;
width: 100%;
height: 76px;
position: fixed;
top: 0;
left: 0;
border-bottom: 2px solid #7e7e7e;
z-index: 100;
display:flex;
}
header h1{
color: #ff0;
background-image: -webkit-linear-gradient(92deg,#f35626,#feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 60s infinite linear;
text-align:center;
flex-direction: column;
}
#search {
float: left;
width: auto;
height: 40px;
flex-direction: column;
}
.itembox {
float: left;
background:green;
flex-direction: column;
}
#search input {
background: none repeat scroll 0 0 #fff;
border: 0 none;
color: #7F7F7F;
float: left;
font: 12px 'Helvetica','Lucida Sans Unicode','Lucida Grande',sans-serif;
height: 20px;
margin: 0;
padding: 10px;
transition: background 0.3s ease-in-out 0s;
width: 300px;
}
#search button {
background: url("search.png") no-repeat scroll center center #7eac10;
cursor: pointer;
height: 40px;
text-indent: -99999em;
transition: background 0.3s ease-in-out 0s;
width: 40px;
border: 2px solid #fff;
}
#search button:hover {
background-color:#000;
}
<header>
<h1>news </h1>
<div id="search">
<form method="post" id="search" action="#">
<input type="text" class="search" value="Type and hit enter" onblur="if(this.value == '') { this.value = 'Type and hit enter'; }" onfocus="if(this.value == 'Type and hit enter') { this.value = ''; }" name="s">
<button type="submit" style="display:inline-block;">Submit</button>
</form>
<div class="itembox">Item box</div>
</div>
</header>

Related

Expand search input field while input within a div using CSS 3

I created a custom 'searchbox'. The 'searchbox' actually built by a div and input text inside it.
Later on I will add a 'search' icon on the left and 'clear' button on the right.
The issue is, the input inside the div already sized based on it's container and when I'm focusing the input text, I couldn't find a way to expand the parent div (instead of the input itself). It's important the div will expand so the icons and buttons I will later add - will expand with the input.
Couldn't find a way doing it with CSS only (without JS).
Will appreciate your assistance!
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.App {
width: 100%;
height: 200px;
background-color: tan;
}
.fieldcontainer {
display: flex;
padding-left: 8px;
background-color: #CCCCCC;
border-color: grey;
width: 300px;
min-height: 35px;
align-items: center;
justify-content: space-between;
border-radius: 8px;
cursor: default;
transition: 'background-color' 0.4s;
}
.fieldcontainer:hover {
background-color: #C3C3C3;
}
.searchfield {
background-color: inherit;
font-size: 1em;
border: 0;
flex-grow: 8;
transition: all 0.4s linear;
}
.searchfield:focus {
outline: none;
width: 100%;
}
</style>
</head>
<body>
<div class="App">
<div class="fieldcontainer">
<input class="searchfield" type="text" placeholder="search" />
</div>
</div>
</body>
</html>
Use focus-within (https://developer.mozilla.org/fr/docs/Web/CSS/:focus-within)
* {
box-sizing: border-box;
}
.App {
height: 200px;
background-color: tan;
}
.fieldcontainer {
display: flex;
padding-left: 8px;
background-color: #CCCCCC;
border-color: grey;
width: 300px;
min-height: 35px;
align-items: center;
justify-content: space-between;
border-radius: 8px;
cursor: default;
transition: 0.4s;
}
.fieldcontainer:hover {
background-color: #C3C3C3;
}
.searchfield {
background-color: inherit;
font-size: 1em;
border: 0;
flex-grow: 8;
transition: all 0.4s linear;
outline:none;
}
.fieldcontainer:focus-within {
width: 100%;
}
<div class="App">
<div class="fieldcontainer">
<input class="searchfield" type="text" placeholder="search" />
</div>
</div>

backface-visibility not working in Firefox (works in Chrome)

backface-visibility not working in Firefox (works in Chrome)
I'm trying to make a form for a credit card that flips over to show the cvc number.
But in Firefox the backside doesn't show at all and the front side shows on both sides, but it works properly in Chrome.
I've tried adding prefixes but it still doesn't work.
Thanks for any help you can give😊
CodePen
HTML:
<div id="on-card-content">
<div id="on-card">
<div id="on-card-inner">
<div id="on-card-front">
<div id="icon-box">
</div>
<div id="number-box">
<label for="on-card-number">Card Number</label>
<input type="text" name="on-card-number" id="on-card-number" placeholder="•••• •••• •••• ••••">
</div>
<div id="name-box">
<label for="on-card-name">Cardholder Name</label>
<input type="text" name="on-card-name" id="on-card-name" placeholder="Your Name">
</div>
<div id="exp-box">
<label for="on-card-exp">Expiry Date</label>
<input type="text" name="on-card-exp" id="on-card-exp" placeholder="MM/YY">
</div>
</div>
<div id="on-card-back">
<div id="swipe-bar"></div>
<input type="text" name="on-card-cvc" id="on-card-cvc" placeholder="123">
<label for="on-card-cvc">CVC</label>
<p id="card-agree">Use of this card is subject to the credit card agreement.</p>
</div>
</div>
</div>
<button type="button" id="card-button"></button>
</div>
CSS:
#on-card-content {
width: fit-content;
width: -moz-fit-content;
}
#on-card {
font-family: 'Source Sans Pro', sans-serif;
width: 320px;
height: 190px;
background: linear-gradient(410deg, #808080 60%, #000000 60%);
margin: 0 auto;
border-radius: 15px;
color: white;
box-shadow: 0 0 15px #0707074d;
transition: transform 0.8s;
transform-style: preserve-3d;
}
#on-card.is-active {
transform: rotateY(-180deg);
box-shadow: 0 0 15px #0707074d;
}
#card-button{
border-radius: 15px;
text-align: center;
margin: 5% 40%;
background: #1a1f71;
color: #ffffff;
border: none;
padding: 10px 10px;
}
#card-button.is-active {
background: #e60404;
}
#card-button::after {
content: 'Next';
}
#card-button.is-active::after {
content: 'Back';
}
#on-card-back {
transform: rotateY(-180deg);
}
#swipe-bar {
background: #000000;
height: 20%;
width: inherit;
margin-top: 5%;
}
#swipe-bar {
background: #000000;
height: 20%;
width: inherit;
margin-top: 5%;
}
#on-card-inner {
background-color: #b3a4a4b3;
border-radius: 15px;
height: inherit;
transition: all 1s ease;
}
#on-card-number {
background: transparent;
border: none;
color: white;
}
#on-card-name {
background: transparent;
border: none;
color: white;
}
#on-card-exp {
background: transparent;
border: none;
color: white;
}
#on-card-front{
transform:rotateY(0deg);
}
#on-card-front,
#on-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
}
#on-card-name {
text-transform: uppercase;
}
#on-card-number {
font-size: 145%;
width: 100%;
}
#icon-box {
height: 5rem;
}
#number-box {
margin-left: 5%;
margin-bottom: 3%;
}
#name-box {
width: 50%;
float: left;
margin-left: 5%;
}
#on-card-name {
width: 100%;
}
#exp-box {
width: 40%;
float: right;
margin-right: 3%;
}
#on-card-exp {
width: 100%;
}
#on-card-cvc {
text-align: right;
margin-top: 5%;
height: 15%;
}
#card-agree {
font-size: 70%;
margin: 5%;
}
JS:
const cardButton = document.getElementById('card-button')
const card = document.getElementById("on-card");
cardButton.addEventListener('click', () => {
card.classList.toggle('is-active')
cardButton.classList.toggle('is-active')
})
The Solution from the "duplicate" Question doesn't solve the issue
I need to remove <div id="on-card-inner"> and rework the colour transition I have on that to the front and back.
Firefox seems to not work when child elements that have child elements that have backface-visibility set to hidden.

Having a issue with css styling for a button that pops out when hovered over

I am very new to CSS as I just started learning it. I've been trying to develop a website as creating a product is the best way for me to learn.
I've created a button that works okay but when hovered the icon pops under the button for a second and then comes back up. I would like to fix that but I'm not sure how.
I've written this;
.sidebar-wrapper {
height: 83%;
width: 110px;
position: absolute;
}
.sidebar-btn {
background-color: rgb(33, 33, 33, 0.5);
height: 8%;
margin-bottom: 35%;
animation: 1s ease-out 0s 1 slideInFromLeft;
width: 110px;
transition: width 0.5s ease;
}
.sidebar-btn img {
float: left;
margin-left: 25px;
margin-top: 8px;
width: 50px;
}
.sidebar-btn label {
font-family: 'Monoton', cursive;
text-align: center;
color: white;
line-height: 60px;
display: none;
font-size: 19;
}
.sidebar-btn:hover {
width: 250px;
}
.sidebar-btn:hover label {
display: inline;
}
.sidebar-clr {
width: 7px;
height: 100%;
float: right;
}
<div class="sidebar-wrapper">
<div class="sidebar-btn">
<label> Profile </label>
<div class="sidebar-clr bg-blue"></div>
<img class="sidebar-img" src="http://via.placeholder.com/50x50/ff0000" />
</div>
</div>
Move your label to after your image, as all the inline styling and scaling means that as it display the label, the image gets pushed out of the way (because it is after your label) and then things snap again when they recalculate themselves the next draw frame. But I think in general there should be better ways to do this, but I am unsure what you are trying to accomplish - the label doesn't actually display in your snippet, it just turns itself to display as block, but the area remains empty, so... Pretty sure a mix of absolute and relative positioning or flexbox, or background-size transition woudl probably work better for your purpose, but I can't say.
.sidebar-wrapper {
height: 83%;
width: 110px;
position: absolute;
}
.sidebar-btn {
background-color: rgb(33, 33, 33, 0.5);
height: 8%;
margin-bottom: 35%;
animation: 1s ease-out 0s 1 slideInFromLeft;
width: 110px;
transition: width 0.5s ease;
}
.sidebar-btn img {
float: left;
margin-left: 25px;
margin-top: 8px;
width: 50px;
}
.sidebar-btn label {
font-family: 'Monoton', cursive;
text-align: center;
color: white;
line-height: 60px;
display: none;
font-size: 19;
}
.sidebar-btn:hover {
width: 250px;
}
.sidebar-btn:hover label {
display: inline;
}
.sidebar-clr {
width: 7px;
height: 100%;
float: right;
}
<div class="sidebar-wrapper">
<div class="sidebar-btn">
<img class="sidebar-img" src="http://via.placeholder.com/50x50/ff0000" />
<label> Profile </label>
<div class="sidebar-clr bg-blue"></div>
</div>
</div>

How to effect other div properties when a different div is hovered on?

this is my 1st post over here, ill try to be as clear as possible and hope I'm following the site's rules.
Not so long ago I started to play a little bit with some HTML/CSS, I got pretty good at it but not enough I guess and I hope to get some help over here.
I'm trying to build a navigation menu and one of it's features I would like it to have is when I hover over the "Account" button it should split the menu in the middle and show a new section where the user can log-in into his or hers account.
This is what I got so far and for some reason I cant make the effect when hovering over the "Account" div but it doe's work when I apply the hover effect on the entire top div (where the "Account div is a part of). tried all "linking" methods suggested in this post and still nothing... Also last thing: When i did overflow: hidden; on the .middle div it added a space between the top and bottom divs.
I would highly appreciate any help and if it's possible to leave it at the CSS level (without any jQuery or any other coding)
Thanks in advance,
Tony.
.container {
width: 560px;
height: auto;
}
.top {
height: 50px;
background-color: red;
}
.top-L {
float: right;
padding: 5px 20px;
}
.top-R {
float: right;
padding: 5px 20px;
height: 50px;
display: block;
}
.middle {
height: 0px;
width: 560px;
overflow: hidden;
background-color: blue;
transition: .4s ease;
}
.bottom {
height: 50px;
background-color: green;
}
.top:hover + .middle {
height: 50px;
transition: .4s ease;
}
.middle:hover {
height: 50px;
}
<html>
<body style="font-family: sans-serif; background-color: #ccc;">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container">
<div class="top">
<div class="top-L">Other</div>
<div class="top-R">Account</div>
</div>
<div class="middle">
<div>
<input type="text" placeholder="Enter Username" name="uname" required>
<input type="password" placeholder="Enter Password" name="psw" required>
</div>
</div>
<div class="bottom"></div>
</div>
</body>
</html>
UPDATED ANSWER
What you are looking for is not possible with your current structure. However, we can do it via Click, Instead of Hover. With some changes :). It is not the perfect solution but should work in your situation.
*{
box-sizing: border-box;
}
.container {
width: 560px;
height: auto;
}
.top {
/* height: 50px; */
background-color: red;
display: flex;
justify-content: flex-end;
}
.top-L label, .top-R label{
padding: 20px;
}
.top-L {
order: 1;
padding: 20px;
}
.top-R {
padding: 20px;
}
.middle {
height: 0px;
width: 560px;
overflow: hidden;
background-color: blue;
transition: .4s ease;
}
.bottom {
height: 50px;
background-color: green;
}
.top:hover + .middle {
/* height: 50px; */
transition: .4s ease;
}
#account{
display: none;
}
#account:checked + .middle{
height: 50px;
padding: 10px;
}
.middle:hover {
/* height: 50px; */
}
<div class="container">
<div class="top">
<div class="top-L">Other</div>
<div class="top-R" ><label for="account">Account</label> </div>
</div>
<input type="checkbox" id="account"/>
<div class="middle">
<div>
<input type="text" placeholder="Enter Username" name="uname" required>
<input type="password" placeholder="Enter Password" name="psw" required>
</div>
</div>
<div class="bottom"></div>
</div>
If I am right this will help you,
nav > ul > li {
display: inline-block
}
nav > ul > li ul {
visibility: hidden;
position: absolute;
top: 105%;
left: 0;
transition: 0.2s 1s;
}
nav > ul > li:hover ul {
visibility: visible;
transition-delay: 0s;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
}
nav li {
width: 100px;
background: #eee;
margin: 2px;
position: relative;
padding: 10px;
}
nav a {
display: block;
}
body {
padding: 10px;
}
<nav>
<ul>
<li>Last</li>
<li>one</li>
<li>is</li>
<li>
Dropdown
<ul>
<li>One</li>
<li>Two</li>
<li>Three</a></li>
</ul>
</li>
</ul>
</nav>
#Tony Mor made some correction on your existing css. I believe it's what you want.
.top-R {
float: right;
padding: 5px 20px;
display: block;
}
and
.middle div {
padding-left: 10px;
padding-top: 15px;
}

Background won't display

So I've took a project from codepen.io and modified it. But now I'm trying to add a background image and I can't display it... Here's my code:
body {
background-image: url("starwars.jpg");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
div.window {
color: white;
width: 500px;
padding: .42rem;
border-radius: 5px;
background: #26466D;
margin: 1rem;
text-align: center;
font-family: BlueHighway, Arial Black, sans-serif;
margin: 0 auto;
}
div.window label {
display: block;
background: #660b0b;
font-size: larger;
border-radius: 5px;
padding: .6rem;
transition: .4s all linear;
}
div.window label:hover {
cursor: pointer; background: #311;
}
input.toggle ~ div {
height: 0px; margin: .2rem;
overflow: hidden;
transition: .6s all cubic-bezier(0.730, -0.485, 0.145, 1.620)
}
input.toggle:checked ~ div { height: 230px; }
input.toggle:checked + label { background: red; }
input.toggle { display: none; }
<div style="height: 240px; padding-top: 1.2rem">
<div class="window">
<input type="checkbox" id="punch" class="toggle">
<label for="punch">Use the Force, Luke.</label>
<div>
<img src="http://images.sequart.org/images/Star-Wars-still-use-the-force-luke-e1415132076759.jpg" style="max-width:100%;height:auto" alt="Ackbar">
</div>
</div>
</div>
If someone could find out why my background image is not displaying, that would be great!
Thanks.
I just tested your code and it works fine so I think what's happening is that the path of your background picture is wrong.
If your starwars image is not in the root folder with your html page then it cannot be url("starwars.jpg");. Check if you didn't put it in another folder or so.
Is the image "starwars.jpg" in the same folder as the .html file that is using it?