I have the following template deisgned to display a listview. But the items in the list assign a background color of black by default. I am not able to override their BG color property. I have experience in native WP developement using C#. But in HTML 5 and WinJS am not able to figure out half the things about design.
HTML Code:
<div id="pivotScenario3" data-win-control="WinJS.UI.Pivot" data-win-options="{ selectedIndex: 4 }">
<div id="listViewMenu" class="listviewpivotitem" data-win-control="WinJS.UI.PivotItem" data-win-options="{ 'header': 'SPORTS' }">
<div data-win-control="WinJS.UI.ListView" data-win-options="{ itemDataSource: All.dataSource, layout: { type: WinJS.UI.ListLayout }, itemTemplate: menuItemTemplate, selectionMode: 'none' }"></div>
</div>
Template code:
<div id="menuItemTemplate" data-win-control="WinJS.Binding.Template">
<div class="menuItem">
<table>
<tr>
<td>
<img data-win-bind="src: logo" alt="Databound image" class="logo" />
</td>
<td>
<div class="selectionmodeHitTarget win-interactive"></div>
<div class="sportNameRoot">
<h2 class="sportName" data-win-bind="innerHTML: sportName"></h2>
</div>
</td>
</tr>
</table>
</div>
</div>
CSS:
.menuItem {
display: -ms-grid;
-ms-grid-columns: 20px 1fr 60px;
-ms-grid-rows: auto auto auto;
background-color: transparent;}
.menuItem .selectionmodeHitTarget {
/* So it is stacked on top of other grid elements */
position: relative;
z-index: 1;
-ms-grid-column: 1;
-ms-grid-row: 1;
-ms-grid-row-span: 3;
width: 16px; /* reserve 4px gap between highlight and item edge */
height: 100%;
transition: background-color 250ms ease-out 250ms, visibility 0ms linear 500ms, transform cubic-bezier(0.17,0.79,0.215,1.0025) 250ms;
}
.menuItem .selectionmodeHitTarget:active {
transition: background-color ease-out 100ms; /* fade in fast */
background-color: Highlight;
}
.menuItem .selectionmodeHitTarget:after {
margin: 0 16px;
width: 16px;
height: 100%;
content: '';
}
.win-selectionmode .menuItem .selectionmodeHitTarget {
transform: translateX(-41px); /* delayed by transition */
visibility: hidden;}
.win-selectionmode .win-item {
overflow: visible;}
CSS for pivot n listview
.listviewpivotitem.win-pivot-item .win-pivot-item-content {
/* Stretch across the whole width of the screen so the whole thing is pannable.*/
padding: 0;
margin: 0;
width: 100%;}
.win-listview {
height: 100%;}
#pivotScenario3 .win-listview .win-container {
margin: 0;
padding: 5px 0 0 0;
background-color: transparent;}
#pivotScenario3 .win-listview.win-rtl .win-item {
margin: 0 0 0 20px;}
#pivotScenario3{
color:white;}
My need is that, i want to set any desired color as background color for listview items.
I know this is a lot of code to go through but my problem is too complicated. Haven't found a solution since a week. This is my last resort.
All help, suggestions and answers are appreciated!
Bind color code with style property
like:
<div data-win-bind="style.background:Color"></div>
it will give you the expected result.
All the Best..!!
Related
I made a custom title bar application and then I gave it a file menu also.(electron)
Now I want to open a menu on click of this menu. I want a popup but the popup shouldn't be the standard windows popup for the menus , I want to make that custom too...but crating a new window can become very tedious if it takes too much time.
Most probably I want to instantiate a section , but I have no idea how to do it
The current situation
I have a window with a #container div having a #buttons div having 3 #minimize,#maximize,#close each with a span
The #buttons also has 2 divs .menu1 and .menu2 i want these menus to behave like normal menus in windows like the file and edit menu
<div id="container">
<nav>
<div id="buttons">
<div id="file">
<span class = "menu1">file</span>
</div>
<div id="about_us">
<span class = "menu2">about..us</span>
</div>
<div id="minimize" onclick="min()">
<span>-</span>
</div>
<div id="maximize" onclick="max()">
<span>+</span>
</div>
<div id="close" onclick="uff()">
<span>×</span>
</div>
</div>
</nav>
</div>
The result is
All the menus and buttons are clickable and have hover colors
Here you need to do something like this:
create the popup window in html and css. Use position: absolute; and z-index to get it to overlay the rest of the application.
Then hide the popup with a css class of for example .hidethat sets the popup to display: none;.
You now need a small piece of javascript to toggle that .hide class. Something like for example a function like this: const togglePopup = () => document.querySelector('.popup').classList.toggle('hide')
Trigger the togglePopup script with the click on one of your elements:
const trigger = document.querySelector('#idOrClassOfTriggerElement')
trigger.addEventListener('click', () => togglePopup()
Add a method for closing the popup with the same type of technique – adding an eventlistener to a trigger element (X icon for example) and calling the same toggle function as in #3.
Hope this was somehow what you wanted to achieve.
EDIT: Example code for a popup overlay:
const popup = document.querySelector('.popup')
const closeBtn = document.querySelector('.popup-close')
const openBtn = document.querySelector('.open')
const body = document.querySelector('body')
const showPopup = () => {
popup.classList.add('fade-in')
body.classList.add('scroll-stop')
}
const hidePopup = () => {
popup.classList.remove('fade-in')
popup.classList.add('fade-out')
body.classList.remove('scroll-stop')
setTimeout(() => {
popup.classList.remove('fade-out')
}, 500)
body.focus();
}
openBtn.addEventListener('click', showPopup)
closeBtn.addEventListener('click', hidePopup)
.popup {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #fefefe;
z-index: 9;
opacity: 0;
pointer-events: none;
overflow: scroll;
}
.popup-inner {
width: 100%;
position: relative;
padding: 6% 16% 0;
}
.popup-close {
position: relative;
z-index: 10;
text-align: center;
color: #aaa;
font-size: 4rem;
cursor: pointer;
position: fixed;
right: 3%;
top: 3%;
}
.popup-close::before {
content: "\00d7";
}
.popup-close:hover::before {
color: #000;
transition: 0.6s all ease-in;
}
.open {
text-align: center;
cursor: pointer;
background: transparent;
padding: 1rem 2rem;
border: 2px solid;
border-radius: 6px;
color: #000;
font-weight: bold;
position: absolute;
top: 25%;
left: 44%;
}
.open:hover {
background: #ffffff18;
}
.fade-in {
opacity: 1;
pointer-events: unset;
transition: 0.3s all ease;
}
.fade-out {
opacity: 0;
pointer-events: none;
transition: 0.3s all ease;
}
.background {
height: 100vh;
width: 100vw;
background: olive;
margin: 0;
padding: 0;
}
<div class="background">
<button class="open">OPEN POPUP</a>
</div>
<!-- Add popup at the bottom of the html document, before </body> -->
<div class="popup" role="dialog" aria-label="Popup">
<div class="popup-close" role="button" arial-label="Close popup" tabindex="1"></div>
<div class="popup-inner">
<h2>This is a popup title</h3>
<p>Popup content...</p>
</div>
</div>
i want to create an interactive wiki with html & css by using a semicircle and dividing the circle into different pieces for each topic. I had the following draft in mind:
https://i.stack.imgur.com/f9Oqp.png
I haven't done html and css in the context of creating own SVGs with animations.
Currently i am using this example as a starting point:
<ul class="menu">
<li class="one">
<a href="#">
<span class="icon">Category 1</span>
</a>
</li>
<li class="two">
<a href="#">
<span class="icon">Category 2</span>
</a>
</li>
<li class="three">
<a href="#">
<span class="icon"> Category 3</span>
</a>
</li>
<svg height="0" width="0">
<defs>
<clipPath clipPathUnits="objectBoundingBox" id="sector">
<path fill="none" stroke="#111" stroke-width="1" class="sector" d="M0.5,0.5 l0.5,0 A0.5,0.5 0 0,0 0.75,.066987298 z"></path>
</clipPath>
</defs>
</svg>
$base: #A5E2F3;
.menu {
padding: 0;
list-style: none;
position: relative;
margin: 30px auto;
width: 70%;
height: 0;
padding-top: 70%;
}
#media all and (max-width: 320px) {
.menu {
width: 230px;
height: 230px;
padding: 0;
}
}
#media all and (min-width: 700px) {
.menu {
width: 500px;
height: 500px;
padding: 0;
}
}
.menu li {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
clip-path: url(#sector);
/* try this one in Chrome/Opera/Safari */
/* clip-path: polygon(50% 50%, 100% 50%, 75% 6.6%); */
a {
display: block;
width: 100%;
height: 100%;
}
&:hover {
background-color: gold;
}
}
.one {
background-color: $base;
transform: rotate(0deg);
}
.two {
background-color: darken($base, 7%);
transform: rotate(-60deg);
}
.three {
background-color: darken($base, 14%);
transform: rotate(-120deg);
}
.icon {
position: absolute;
/* exact values here depend on what you are placing inside the items (icon, image, text, etc.) */
right: 15%;
top: 30%;
/* make sure it it rotated enough; angle of rotation = angle of the sector itself */
transform: rotate(60deg);
/* style further as needed */
color: darken($base, 60%);
font-family: Indie Flower;
font-size: 25px;
}
p {
text-align: center;
width: 80%;
margin: 0 auto;
}
These are my question about this task:
1) How can i create interactive buttons
- click on the button will make the remaining buttons disappear
- 1/3 semicircle will expand to a 1/4 semicicircle
2) How can i improve the clicks with animations
- Button Grows from 1/3 to 1/4 semicircle
Thank you in advance!
To answer your questions:
1). An interactive button can be created in many ways, personally I would do something like this in HTML:
<button type="button" data-toggle="menuItem">Toggle</button>
and then in JavaScript (using jQuery) you can check for when this button is clicked:
$("button[data-toggle='menuItem']").on("click", function () {
// - Do your toggle logic in here
// - Do '.hide()' on all buttons that aren't '$(this)'.
// - Add class to '$(this)' to make it expand.
});
2). It really depends on how you're creating your semi-circles but I would say your best cross-browser solution would be to look into the CSS 'transition' property a bit more: W3Schools CSS transition Property
I hope this helps, let me know if you don't understand something I've said.
I have the following design:
and each time I hover an attachment, I have the ability to delete it:
Sometimes, when having many attachments and I hover an attachment the row is too long and the last attachment in the row jumps to the next row.
I tried to google it and found the usage of (nth-last(4n)) but I don't know how many items i have in each row.
I thought about something like this:
last-child-in-a-row { margin-right: 10px; }
So, in that case i will have enough space for the growing x element.
Is there any suggested workaround/best-practice for this?
EDIT:
HTML (rendered from React):
<div class="attachmentHolder">
<button class="attachmentButton">
<svg class="leftAttachment" ... />
<a ...> some text </a>
<svg class="attachmentClose" ... />
</button>
<button class="attachmentButton">
<svg class="leftAttachment" ... />
<a ...> some text 2 </a>
<svg class="attachmentClose" ... />
</button>
...
...
</div>
CSS:
.attachmentHolder {
display: flex;
flex-wrap: wrap;
}
.attachmentButton {
padding-right: 0;
padding-left: 6px;
margin: 0 8px 10px 0;
.attachmentClose {
max-width: 0;
transition: max-width .1s ease-out, margin-left .1s ease-out;
}
&:hover {
.attachmentClose {
max-width: 25px;
margin-left: 8px;
margin-right: 8px;
fill: $secondary;
}
}
}
.leftAttachment {
height: 20px;
width: 15px;
margin: 0 4px 3px 0;
}
I'm trying to create an animated slider so that the "non-active" slides are still shown on the sides.
The height of the children is not known. Also, when resizing the page, the height might increase.
Currently I have this: https://codepen.io/anon/pen/odoYPx
HTML:
<div class="row side-by-side-slider">
<div class="col-md-6 ss-slide-left ss-slide">
<div class="ss-slide-content">
Content
</div>
</div>
<div class="col-md-6 ss-slide active">
<div class="ss-slide-content">
Content
</div>
</div>
<div class="col-md-6 col-md-push-10 ss-slide">
<div class="ss-slide-content">
Content
</div>
</div>
</div>
CSS:
body {
overflow: hidden;
}
.side-by-side-slider {
overflow: hidden;
}
.side-by-side-slider .ss-slide {
position: absolute;
opacity: .26;
margin: 0 15px;
background: #f5f4f4;
-webkit-box-shadow: 0 0 40px 0 #F5F4F4;
box-shadow: 0 0 40px 0 #F5F4F4;
border-radius: 10px;
padding: 45px 70px;
width: 50%;
-webkit-transition: all .5s ease;
transition: all .5s ease;
}
.side-by-side-slider .ss-slide-left {
left: -33.3333333%;
}
.side-by-side-slider .ss-slide.active {
left: 25%;
opacity: 1;
}
.col-md-push-10 {
left: 83.33333333%;
}
The problem is that the parent (.side-by-side-slider) doesn't wrap around the children. I couldn't figure out how to do it without children being "position: absolute" since then I had alignment issues. I left out the slider JS code because for this problem it's not necessary. It's still a work in progress.
Any help is appreciated!
https://codepen.io/7ssan91/pen/RyjVNW you can use this slider with only Html and Css if you want to control of the height you should use media query https://www.w3schools.com/css/css_rwd_images.asp
I was just wondering if there was a pure CSS solution, but couldn't make one.
I ended up using jQuery to achieve this. More specifically this function:
makeChildHeight() {
let maxHeight = $('.side-by-side-slider .ss-slide').innerHeight() + 80;
Array.prototype.forEach.call($('.side-by-side-slider .ss-slide'), function(slide) {
if ($(slide).innerHeight() + 80 > maxHeight) {
maxHeight = $(slide).innerHeight() + 80;
}
});
$('.side-by-side-slider').css(
{'height': maxHeight}
);
}
This question already has answers here:
How do I vertically align text in a div?
(34 answers)
Closed 6 years ago.
What the hell am I doing wrong haha.
I don't want to set the div's height because it should be set to auto depending on the image next to it. Am I using the tag wrong or something?
See my attached code.
Any help is greatly appreciated.
*{margin:0;padding:0;box-sizing:border-box;}
.hugme{margin:0 auto;max-width:947px;}
[class*=bit-]{float:left;padding:5px;}
#font-face {
font-family: 'Market Deco';
font-style: normal;
font-weight: normal;
src: local('Market Deco'), url('http://www.adambwhitten.com/obsw/Market_Deco.woff') format('woff');
}
/* Grids */
.box{background:#ed1b2e;font-family: 'Open Sans', sans-serif;font-size:14px;font-weight:700;text-align:center;padding:10px 0;}
.box-2{background:#00aabe;}
.bit-1{width:100%;}
.bit-2{width:50%;}
.bit-2-2{width:50%;}
.bit-3{width:33.33333%;}
.bit-4{width:25%;}
.bit-5{width:20%;}
.bit-6{width:16.66667%;}
.bit-7{width:14.28571%;}
.bit-8{width:12.5%;}
.bit-9{width:11.11111%;}
.bit-10{width:10%;}
.bit-11{width:9.09091%;}
.bit-12{width:8.33333%;}
.bit-25{width:25%;}
.bit-40{width:40%;}
.bit-60{width:60%;}
.bit-75{width:75%;}
.bit-35{width:35%;}
.bit-65{width:65%;}
.holdsmaller{max-width: 960px; margin: 0 auto;}
/* Buttons / Video Styles */
.holdbutton1 {
z-index:899;
margin: 10px;
}
.holdbutton2 {
z-index:899;
margin: 10px;
}
.holdbutton3 {
z-index:899;
margin: 10px;
}
.button-wrapper{
position:absolute;
width:100%;
height: 100%;
display:flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.btnFall {
-webkit-border-radius: 5;
-moz-border-radius: 5;
border-radius: 5px;
color: #ffffff;
width:200px;
font-size: 14px;
background: #772539;
padding: 10px 20px 10px 20px;
text-decoration: none;}
.btnFall:hover {
background: #959356;
text-decoration: none;
}
#media only screen and (max-width: 756px){
.button-wrapper{flex-direction: column;}
}
#cf {position:relative; width:100%; margin:0 auto;}
#cf img {position:absolute; left:0; width:100%; height:auto; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease-in-out; transition: opacity 1s ease-in-out;}
#cf img.top:hover{opacity:0;}
.showmobile{display:none;}
/* Responsive Goodness */
/* Defaults above are set Desktop resolution or higher */
/* Laptop */
#media (min-width:50em) and (max-width:68.75em){
.bit-7,.bit-35,.bit-65{width:100%;}
.bit-10,.bit-12,.bit-4,.bit-8{width:50%;}
}
/* Tablet */
#media (min-width:30em) and (max-width:50em){
.bit-10,.bit-12,.bit-4,.bit-6,.bit-8{width:50%;}
.bit-1,.bit-11,.bit-3,.bit-5,.bit-7,.bit-9{width:100%;}
img.product {margin-top:43px;}
img.product2 {margin-top:56px;}
}
/* Mobile */
#media (max-width:30em){
.bit-4{width:50%;}
.bit-1,.bit-10,.bit-11,.bit-12,.bit-2,.bit-3,.bit-5,.bit-6,.bit-7,.bit-8,.bit-9{width:100%;}
#cf, img.product, img.product2, img.hidemobile, .button-wrapper {display:none;}
.showmobile {display:block;}
}
<div class="hugme">
<div class="bit-2">
<div class="inner" style="vertical-align:middle;">
<font style="font-family:'Market Deco'; font-size:50px; color:#772539;">BOOT UP</font><br>
<font style="font-size:18px; color:#000;">Short, tall, over the knee, or with plush touches.<br>This fall, take your pick.</font>
<div class="btnFall" style="text-align:center;">SHOP NOW ></div>
</div>
</div>
<div class="bit-2">
<div id="cf">
<a href="http://www.google.com/">
<img class="bottom" src="http://i.imgur.com/J3DOMlR.jpg" width="100%"/> <!-- hover -->
<img class="top" src="http://i.imgur.com/dMmmOz9.jpg" width="100%"/> <!-- static -->
</a>
</div>
</div>
</div>
Thanks guys and gals!
According to MDN, vertical-align is a property used for inline elements. I don't think it would work on a div.