I have an element that I have tried every known way to click on here are a few:
var areaMap = $('[data-bind="click: campusMap"]');
var areaMap = browser.driver.findElement(By.cssSelector("div.campus-map.panel > div.panel-footer > button.btn.btn-browse")).click();
var areaMap = element(by.cssContainingText('button.btn', "View Area Map"));
//and this way too
browser.executeScript('arguments[0].click()', areaMap.getWebElement());
browser.actions().mouseMove(areaMap).click().perform();
I have no idea how to make this element interact-able.
The HTML looks like this:
<div class="campus-map panel" data-bind="click: campusMap">
<div class="title">Area Map</div>
<div class="panel-content">
<div id="googleContainer" style="position: relative; background-color: rgb(229, 227, 223); overflow: hidden;">
<div class="gm-style" style="position: absolute; left: 0px; top: 0px; overflow: hidden; width: 100%; height: 100%; z-index: 0;">
<div style="position: absolute; left: 0px; top: 0px; overflow: hidden; width: 100%; height: 100%; z-index: 0; cursor: pointer;">
<div style="margin-left: 5px; margin-right: 5px; z-index: 1000000; position: absolute; left: 0px; bottom: 0px;">
<div class="gmnoprint" style="z-index: 1000001; position: absolute; right: 166px; bottom: 0px; width: 121px;">
<div style="background-color: white; padding: 15px 21px; border: 1px solid rgb(171, 171, 171); font-family: Roboto,Arial,sans-serif; color: rgb(34, 34, 34); box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.2); z-index: 10000002; display: none; width: 256px; height: 118px; position: absolute; left: 36px; top: 5px;">
<div class="gmnoscreen" style="position: absolute; right: 0px; bottom: 0px;">
<div class="gmnoprint gm-style-cc" style="z-index: 1000001; position: absolute; -moz-user-select: none; right: 95px; bottom: 0px;" draggable="false">
<div class="svg-controls" style="z-index: 0; position: absolute; bottom: 13px; right: 0px;">
<div class="gm-style-cc" draggable="false" style="-moz-user-select: none; position: absolute; right: 0px; bottom: 0px;">
</div>
</div>
</div>
Your example code has elements that do not exist in your html example... so I'm not 100% sure what you're trying to click on. But assuming it's the first div, and assuming it's visible, this selector should work:
var areaMap = $('div.campus-map.panel');
or if that's NOT visible, perhaps this (since title should be visible):
var areaMap = $('div.campus-map.panel div.title');
Or with text:
var areaMap = element(by.cssContainingText('div.title', "Area Map"));
Related
I am trying to fit in a flex container with margins on both sides inside a grid container, but at the smallest viewport width the flex container leaks out. I have added borders to the respective divs to show where its leaking.
I have also added a demo to show my problem: https://codesandbox.io/s/9z49m3ny0p
If the demo isn't clear, take a look at these screenshots:
As you see from the above screenshots, that the red border stays within the viewport at all times but the blue bordered container spills out.
Home.js
<div id="rightContainer">
<div id="editorContainer">
<Notepad />
</div>
<div id="notesCardContainer">
<NoteCard />
<NoteCard />
</div>
</div>
Home.css
#editorContainer {
display: grid;
width: 100%;
position: relative;
border: 1px solid red;
}
#notesCardContainer {
display: grid;
width: 100%;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
flex-direction: row;
justify-content: space-evenly;
padding-bottom: 60px;
}
And Notepad.js :
<div className="editorInnerContainer">
<div className="editorTop">
<input
type="text"
id="noteTitle"
value="Some Title"
disabled={true}
/>
<div id="tools">
<a href="" title="Edit this note">
<i className="fas fa-pencil-alt" />
</a>
<a href="" title="Delete this note">
<i className="fas fa-trash" />
</a>
<a href="" title="Download this note">
<i className="fas fa-download" />
</a>
<a href="" title="Share this note">
<i className="fas fa-share-square" />
</a>
</div>
</div>
</div>
Snippet from Notepad.css
.editorInnerContainer {
display: flex;
flex-direction: column;
background-color: var(--white-100);
padding: 20px;
margin-left: 20px;
margin-right: 20px;
margin-top: 50px;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.14);
border: 1px solid blue;
}
Take a look at this:
https://codesandbox.io/s/2v0o67w4kn
#noteTitle {
flex: 1;
height: 60px;
font-size: 18px;
line-height: 17px;
font-weight: 700;
border: none;
color: var(--black);
border: 2px solid sandybrown;
/* add width */
width: 100%;
max-width: 100%;
}
If you want to adjust the border issue as well, set the width to 100% - the border sizes added together via calc: https://codesandbox.io/s/l7rk0zop69
#noteTitle {
width: calc(100% - 6px);
max-width: calc(100% - 6px);
}
I have this responsive website, but for the menu part in Mobile when I scroll it doesn't show the buttons anymore, I should scroll back to the top to get to the buttons.
I don't know why the buttons in the mobile menu don't scroll within the screen.
HTML
/* ------------------------------------------------------------------------------
Header
-------------------------------------------------------------------------------*/
#header {
position: fixed;
width: 100%;
z-index: 999;
}
#header .header-content {
margin: 0 auto;
max-width: 1170px;
padding: 20px 0;
width: 100%;
-moz-transition: padding 0.3s;
-o-transition: padding 0.3s;
-webkit-transition: padding 0.3s;
transition: padding 0.3s;
}
#header .logo {
float: right;
font-size:24px;
font-weight:700;
color:#fff;
text-decoration:none;
text-transform:uppercase;
letter-spacing:7px;
}
#header.fixed {
background-color: #181818;
padding: 0;
-moz-transition: background-color 0.3s;
-o-transition: background-color 0.3s;
-webkit-transition: background-color 0.3s;
transition: background-color 0.3s;
}
#header.fixed a {
color: #fff;
}
#header.fixed .header-content {
border-bottom: 0;
}
#header.fixed .nav-toggle {
top: 18px;
color: #000;
}
.navigation.open {
opacity: 0.9;
visibility: visible;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.navigation {
float: left;
padding-top: 20px;
}
.navigation li {
display: inline-block;
}
.navigation a {
color: rgba(255, 255, 255, 0.75);
font-size: 20px;
margin-left: 40px;
text-transform: uppercase;
}
.navigation a:hover, .navigation a.active {
color: #fff;
}
.nav-toggle {
display: none;
height: 44px;
overflow: hidden;
position: fixed;
left: 5%;
text-indent: 100%;
top: 32px;
white-space: nowrap;
width: 44px;
z-index: 99999;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.nav-toggle:before, .nav-toggle:after {
border-radius: 50%;
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-webkit-transform: translateZ(0);
transform: translateZ(0);
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
-webkit-transition-property: -webkit-transform;
transition-property: transform;
}
.nav-toggle:before {
background-color: #1192cf;
-moz-transform: scale(1);
-ms-transform: scale(1);
-webkit-transform: scale(1);
transform: scale(1);
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.nav-toggle:after {
background-color: #1192cf;
-moz-transform: scale(0);
-ms-transform: scale(0);
-webkit-transform: scale(0);
transform: scale(0);
-moz-transition-duration: 0s;
-o-transition-duration: 0s;
-webkit-transition-duration: 0s;
transition-duration: 0s;
}
.nav-toggle span {
background-color: #fff;
bottom: auto;
display: inline-block;
height: 3px;
left: 50%;
position: absolute;
right: auto;
top: 50%;
width: 18px;
z-index: 10;
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
.nav-toggle span:before, .nav-toggle span:after {
background-color: #fff;
content: "";
height: 100%;
position: absolute;
right: 0;
top: 0;
width: 100%;
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-webkit-transform: translateZ(0);
transform: translateZ(0);
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-transition: -moz-transform 0.3s;
-o-transition: -o-transform 0.3s;
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
}
.nav-toggle span:before {
-moz-transform: translateY(-6px) rotate(0deg);
-ms-transform: translateY(-6px) rotate(0deg);
-webkit-transform: translateY(-6px) rotate(0deg);
transform: translateY(-6px) rotate(0deg);
}
.nav-toggle span:after {
-moz-transform: translateY(6px) rotate(0deg);
-ms-transform: translateY(6px) rotate(0deg);
-webkit-transform: translateY(6px) rotate(0deg);
transform: translateY(6px) rotate(0deg);
}
.nav-toggle.close-nav:before {
-moz-transform: scale(0);
-ms-transform: scale(0);
-webkit-transform: scale(0);
transform: scale(0);
}
.nav-toggle.close-nav:after {
-moz-transform: scale(1);
-ms-transform: scale(1);
-webkit-transform: scale(1);
transform: scale(1);
}
.nav-toggle.close-nav span {
background-color: rgba(255, 255, 255, 0);
}
.nav-toggle.close-nav span:before, .nav-toggle.close-nav span:after {
background-color: #fff;
}
.nav-toggle.close-nav span:before {
-moz-transform: translateY(0) rotate(45deg);
-ms-transform: translateY(0) rotate(45deg);
-webkit-transform: translateY(0) rotate(45deg);
transform: translateY(0) rotate(45deg);
}
.nav-toggle.close-nav span:after {
-moz-transform: translateY(0) rotate(-45deg);
-ms-transform: translateY(0) rotate(-45deg);
-webkit-transform: translateY(0) rotate(-45deg);
transform: translateY(0) rotate(-45deg);
}
#media screen and (max-width: 1024px) {
#header .header-content {
width: 90%;
padding:20px 0px;
}
#header.fixed a {
color: #000;
}
.nav-toggle {
display: block;
}
.navigation {
position: fixed;
background-color: #000;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 99999;
visibility: hidden;
opacity: 0;
-webkit-transition: opacity 0.5s, visibility 0s 0.5s;
transition: opacity 0.5s, visibility 0s 0.5s;
}
.navigation .primary-nav {
position: relative;
top: 45%;
-moz-transform: translateY(-45%);
-ms-transform: translateY(-45%);
-webkit-transform: translateY(-45%);
transform: translateY(-45%);
}
.navigation li {
display: block;
margin-bottom: 20px;
}
.navigation a {
display: block;
font-size: 25px;
margin: 0;
text-align: center;
}
.flex-control-nav {
bottom: 20px;
}
}
<header id="header">
<div class="header-content clearfix"> <a class="logo" href="index.html"><img style="logo-size" src="images/logo-awaed.png" width="150px" height="62px"></a>
<nav class="navigation" role="navigation">
<ul class="primary-nav">
<li>عن الشركة</li>
<li>خدماتنا</li>
<li>اتصل بنا</li>
</ul>
</nav>
Menu<span></span> </div>
</header>
Don't reinvent the wheel. Read the Bootstrap documentation and use the navbar and the navbar components Bootstrap 4 provides.
Here's a working navbar example:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Reference:
https://getbootstrap.com/docs/4.0/components/navbar/
Below how it looks :
Below What I would like to have :
or if getNumber return more for example
(so basicaly the circle are always align center whatever number my getNumber return)
Below the AngularJS code :
<div class="w3-container">
<span ng-repeat="i in getNumber(data.numberOfState) track by $index" style="margin-right:10%;">
<div id="advanced" class="circle" ></div>
</span>
<div id="barre"></div>
</div>
Below the CSS code :
.circle {
border-radius: 50%;
width: 18px;
height: 18px;
background: RoyalBlue;
display: inline-block;
}
#barre{
width: 100%;
height: 3px;
background: RoyalBlue;
margin-top: -17px;
}
#advanced {
width: 18px;
height: 18px;
/* TODO */
}
.circleActive {
border-radius: 40%;
width: 15px;
height: 15px;
background: RoyalBlue;
display: inline-block;
}
How to align center the circle on the bar ?
right: 50%;
left: 50%;
position: absolute;
With this it works but since my circle are iterate by my javascript there are showing at the same coordinated, so I can see only one.
Add text-align:center; to .circle parent
.w3-container {text-align:center;}
Here's small snippet for you
.parent {text-align:center;}
.child {height:14px; width:14px; background:royalblue; display:inline-block;}
<div class="parent">
<span class="child"></span>
</div>
<div class="parent">
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
</div>
<div class="parent">
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
</div>
This is easy if you are using a flexbox - you only need to give:
display:flex;
width:100%;
justify-content: space-around;
Some suggestions though:
Using id inside an ng-repeat is wrong, as you will then get multiple ids which is invalid.
barre is omitted and using an after psuedo element just for more markup readability.
The line (using after) is absolutely positioned with respect to the flexbox
See demo below:
.circle {
border-radius: 50%;
width: 18px;
height: 18px;
background: RoyalBlue;
display: inline-block;
}
.wrapper {
display:flex;
width:100%;
justify-content: space-around;
position:relative;
}
.wrapper:after {
position:absolute;
content:'';
display:block;
width: 100%;
top:7px;
height: 3px;
background: RoyalBlue;
}
.advanced {
width: 18px;
height: 18px;
}
.circleActive {
border-radius: 40%;
width: 15px;
height: 15px;
background: RoyalBlue;
display: inline-block;
}
<div class="w3-container">
<div class="wrapper">
<div class="circle advanced" ></div>
<div class="circle advanced circleActive" ></div>
<div class="circle advanced" ></div>
</div>
</div>
You can use display: flex; for container. To center elements add justify-content: center;.
.line {
display: flex;
justify-content: center;
margin: 50px;
border-top: 2px solid blue;
}
.circle {
flex: 0 0 auto;
width: 20px;
height: 20px;
margin: 0 20px;
background-color: blue;
border-radius: 50%;
transform: translateY(-50%);
}
<div class="line">
<div class="circle"></div>
</div>
<div class="line">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<div class="line">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
I'm using Angularjs in order to display some images in the DOM, and apply some style to them (dim the background). It seems I am unable to apply ng-style to the img tag. What is the reason to that?
Fiddle here.
HTML:
<div ng-controller="MyController">
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12 postCon" ng-repeat="post in posts">
<div class="rel">
<img src="{{post.link}}" alt="..." class="img-thumbnail" ng-click="test()" ng-style="{'background':'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('+post.link+')','background-size': 'cover'}">
<li class="del">button</li><li class="getLink">get link</li>
</div>
</div>
</div>
</div>
CSS:
.del{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
}
.getLink{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
right: 0;
bottom: 0;
}
.rel{
position: relative;
height: auto;
width: auto;
display: inline-block;
}
Please try the following:
HTML:
<div ng-controller="MyController">
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12 postCon" ng-repeat="post in posts">
<div class="rel">
<div class="cover-img">
<img src="{{post.link}}" alt="..." class="img-thumbnail" ng-click="test()" style="background:linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));background-image: url('{{post.link}}');background-size: cover">
</div>
<li class="del">button</li><li class="getLink">get link</li>
</div>
</div>
CSS:
.del{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
}
.getLink{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
right: 0;
bottom: 0;
}
.rel{
position: relative;
height: auto;
width: auto;
display: inline-block;
}
.cover-img{
position:relative;
}
.cover-img:before{
content:'';
background: rgba(69, 71, 94, 0.53);
position:absolute;
left:0;
right:0;
bottom:0;
top:0;
width:100%;
height:100%;
}
I don't think that how ng-style works. You can see example here and here.
Try this:
In html:
<img ng-style="yourStyle">
In controller:
$scope.yourStyle =
{
'background': 'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))',
'background-size': 'cover'
}
Hope this help.
I'm trying to create a dynamically array(arr) with a length of ng-model(numberFloor) from input[range].
var app = angular.module("houseBuilder", ['ngSanitize']);
app.controller('myCtrl', function($scope) {
$scope.numberFloor = 1;
$scope.floor = '<div class="home-floor"><div class="home-floor-window"></div><div class="home-floor-window"></div></div>';
$scope.arr = [$scope.numberFloor]; // How to bind a dynamically array with length equal numberFloor?
});
.home {
display: inline-block;
width: 300px;
}
.home-roof {
width: 0;
height: 0;
border-left: 150px solid transparent;
border-right: 150px solid transparent;
border-bottom: 100px solid black;
position: relative;
}
.home-roof:after {
content:'';
position:absolute;
top: 4px;
left: -137px;
width: 0;
height: 0;
border-left: 137px solid transparent;
border-right: 137px solid transparent;
border-bottom: 92px solid white;
}
.home-floor {
height: 100px;
border-right: 5px solid black;
border-left: 5px solid black;
}
.home-floor-window {
display: inline-block;
box-sizing: border-box;
width: 50px;
height: 70px;
border: 3px solid blue;
margin: 15px 40px;
}
.home-groundfloor {
height: 100px;
border-right: 5px solid black;
border-left: 5px solid black;
border-bottom: 5px solid black;
}
.home-groundfloor-door {
float: right;
box-sizing: border-box;
width: 60px;
height: 90px;
border: 3px solid red;
margin: 10px 30px 0 0;
}
.controller {
display: inline-block;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>House builder</title>
<link rel="stylesheet" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.5.0-rc.0/angular-sanitize.min.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-app="houseBuilder" ng-controller="myCtrl">
<div class="home">
<div class="home-roof"></div>
<div ng-repeat="n in arr" ng-bind-html="floor"></div>
<div class="home-groundfloor">
<div class="home-groundfloor-door"></div>
</div>
</div>
<div class="controller">
<input type="range" min="1" max="10" ng-model="numberFloor">
<input type="text" value="{{numberFloor}}">
</div>
</body>
</html>
What is the easiest way in angular to bind value of ng-model to length of an array so that length changes when ng-model changes?
The simplest way is to just you array.length attribute like so:
<input type="range" min="0" max="100" ng-model="array.length">
Here's a working example:
angular.module('test', []);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form ng-app="test" ng-init="array = []">
<input type="range" min="0" max="100" ng-model="array.length">
<p>{{array|json}}</p>
</form>