How to make javascript button be in fixed place on different screen sizes? - responsive-design

when I view my website on different screen sizes, the button and equalizer move to different points. so how to make it's position fixed on any screen size?
button html code:
<div id="player" class="player">
<i id="playback" class="fa fa-play fa-3x"></i>
</div>
<audio controls loop style="display:none">
<source src="http://streaming.radionomy.com/MSTC-CHI" type='audio/ogg'>
<source src="http://streaming.radionomy.com/MSTC-CHI" type='audio/mpeg'>
</audio>
css code:
#playback {
position: absolute;
top: 30%;
left: 40%;
width:auto;
color:white;
}
#player:after {
position: absolute;
content: '';
width: 150px;
height: 150px;
left: 0;
color:white;
border-radius: 50%;
-webkit-transform: rotate(4deg);
transform: rotate(-75deg);
}
#playback {
position: absolute;
color:white;
left:29.7%;
top:46.25%;
text-shadow: 0 0 40px #fff;
}
.fa-stop{
margin-left:-0.46%;
}
#player{
-moz-transition: all 0.8s ease-in-out;
-webkit-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
transition: all 0.8s ease-in-out;
}
#player:hover{
box-shadow: 0 0px 20px #fff;
}
I've tried to make the display block, margin auto, position absolute, and determine top and left position.
#player {
display: block;
margin: 0 auto;
top: 46%;
left: 30%;
position: absolute;
}
#music-bar {
display: block;
margin: 0 auto;
top: 75%;
left: 58%;
position: absolute;
}
but still not working. any idea how to fix this issue?
thanks in advance.

Try to use following snippet.
position:absolute;
top: 50;
right:0;
In your example you use percentages. I think what you should use is absolute numbers (in pixels for example).
The element will be placed at the top right with 50 pixels distance to the top.

Related

How to design a UI Component like this in React?

I got the requirement for developing a UI component for teams-info like this.
I have just started using React with React-Bootstrap, but I couldn't find a UI layout which can render this. I have used react-responsive-carousel, but It's a flat icon at the bottom of the image as Thumbnail not like a half-circular option shown in the image.
Update:
On selecting another image the image positions must not change. Like this.
Can anyone guide me how can I achieve this?
Thanks in advance.
Something like this may bring you closer to the result. One way of mapping the user information in the middle would be through utilizing different pieces of content in an array.
function Circle() {
function elementMethod(){
return (
<span onMouseEnter={...} onMouseLeave={...} className='individual--circ'><img src={...}></img> </span>
}
return (
<React.Fragment>
{ circleElement.map((element) => {
<div classname='cir-menu'>
{element}
</div>
}
</React.Fragment>
)
}
I've built something similar before which has a similar appearance (animated, however). The CSS looked like this:
.contact-icon{
background-color: #000000;
border-radius: 50%;
padding: 20px;
box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.1),
2px 2px 2px 2px rgba(0,0,0,0.1),
4px 4px 4px 4px rgba(0,0,0,0.1);
}
.middle-cir{
position: relative;
}
.contact-outer{
background-color: #611427;
color: white;
height: 100vh;
width: 100vw;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
margin: 0;
opacity: 100;
visibility: visible;
z-index: 4;
transition: visibility .5s, opacity 1s ease;
}
.contact-outer h1{
top: 0;
margin-top: 4em;
position: absolute;
opacity: 100
}
.contact-outer-none h1{
top: 0;
margin-top: 4em;
position: absolute;
}
.contact-outer-none{
background-color: #611427;
color: #F2F2E9;
height: 100vh;
width: 100vw;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
margin: 0;
opacity: 0;
visibility:hidden;
z-index: 4;
transition: visibility .5s,opacity 1s ease;
}
.cir-menu{
position: relative;
justify-self: center;
display: flex;
justify-content: center;
align-items: center;
transform: rotate(-87deg);
}
.cir-a{
position: absolute;
transform: rotate(72deg) translateX(80px) rotate(10deg);
transition: transform 1s;
}
.cir-a:hover{
position: absolute;
transform: rotate(72deg) translateX(110px) rotate(10deg);
}
.cir-a-min{
position: absolute;
transform: rotate(72-20deg) translateX(0px) rotate(-72deg);
transition: transform 1s;
}
.cir-b{
position: absolute;
transform: rotate(144deg) translateX(80px) rotate(-60deg);
transition: transform 1s;
}
.cir-b:hover{
position: absolute;
transform: rotate(144deg) translateX(110px) rotate(-60deg);
}
.cir-b-min{
position: absolute;
transform: rotate(144-20deg) translateX(0px) rotate(-144deg);
transition: transform 1s;
}
.cir-c{
position: absolute;
transform: rotate(216deg)translateX(80px) rotate(-132deg);
transition: transform 1s;
}
.cir-c:hover{
position: absolute;
transform: rotate(216deg) translateX(110px) rotate(-132deg);
}
.cir-c-min{
position: absolute;
transform: rotate(216-20deg) translateX(0px) rotate(-216deg);
transition: transform 1s;
}
.cir-d{
position: absolute;
transform:rotate(288deg) translateX(80px) rotate(-204deg);
transition: transform 1s;
}
.cir-d:hover{
position: absolute;
transform: rotate(288deg) translateX(110px) rotate(-204deg);
}
.cir-d-min{
position: absolute;
transform:rotate(288-20deg) translateX(0px) rotate(-288deg);
transition: transform 1s;
}
.cir-e{
position: absolute;
transform: rotate(360deg) translateX(80px) rotate(-276deg);
transition: transform 1s;
}
.cir-e:hover{
position: absolute;
transform: rotate(360deg) translateX(110px) rotate(-276deg);
}
.cir-e-min{
position: absolute;
transform: rotate(360-20deg) translateX(0px) rotate(-360deg);
transition: transform 1s;
}
.nav-icon-ctr{
visibility: visible !important;
background-color: #F2F2E9;
position: relative;
justify-self: center;
align-self: center;
z-index: 99;
border-radius: 50%;
color: black;
height: 20px;
width: 20px;
padding: 1rem;
transform: rotate(87deg);
box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2),
3px 3px 3px 3px rgba(0,0,0,0.2);
}

why is Hover effect opacity not working after build

I Have a simple hover effect on a button that is nested in a link.
Here is the button :
<Link to={`/product/${product._id}`} >
<button className='btn-4'>View </button>
</Link>
and here is the css for it :
.btn-4 {
padding: 10px;
width: 40%;
border: none;
background-color: var(--drk-black);
color: var(--light-grey-2);
font-size: 18px;
text-transform: uppercase;
letter-spacing: var(--spacing);
position: absolute;
width: 100%;
height: 100%;
z-index: 2;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
opacity: 0;
}
.btn-4:hover {
opacity: 50%;
cursor: pointer;
}
It works normally on localhost but the opacity is not changing after building however the cursor is becoming a pointer.
Can somebody explain to me why this is happening please?
I was able to fix this thanks to this answer :
opacity percentage changed to 1%
so I ended up changing the opacity from 50% to 0.5.

PrimeReact DataTable: How to (visually) deselect rows

I'm using a DataTable that has row selection via checkbox as well as a global search. The problem is that if I select one (or more) rows and then filter via the global search, the positions of the selected rows stay the same, e. g. if I select row one and two and filter, row one and two are still selected even if they have completely different content now because of the filtering. I even managed to reset the underlying selection in the state leading to nothing being selected in the state but the checkboxes are still checked. Resetting the DataTable doesn't do anything.
How do I (at least visually) reset the checkboxes? Thanks!
My code is as follows:
<InputText type="search" onInput={e =>
this.setState({
globalFilter: e.target.value,
selectedProjectListEntries: []
})}
placeholder={this.intl.formatMessage({id: "input.global-search.hint"})}
className={"form-control"}/>
<DataTable ref={el => this.dataTable = el}
value={this.state.projectListEntries} autoLayout={false}
globalFilter={this.state.globalFilter} rows={20}
className={'table table-striped'}
selection={this.state.selectedProjectListEntries}
onSelectionChange={e => this.setState({selectedProjectListEntries: e.value})}>
<Column selectionMode="multiple"/>
... Columns ...
If anyone else is using the DataTable without PrimeReact's CSS and theme, the following CSS is necessary to get it to work (in addition to using PrimeIcons):
body .p-checkbox {
display: inline-block;
vertical-align: middle;
margin: 0;
width: 20px;
height: 20px;
}
.p-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.p-hidden-accessible input, .p-hidden-accessible select {
-webkit-transform: scale(0);
transform: scale(0);
}
body .p-checkbox .p-checkbox-box.p-highlight {
border-color: $highlight_color;
background-color: $highlight_color;
color: #ffffff;
}
body .p-checkbox .p-checkbox-box {
border: 1px solid #a6a6a6;
background-color: #ffffff;
width: 20px;
height: 20px;
text-align: center;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
-o-transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
-webkit-transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.p-checkbox .p-checkbox-box {
width: 1.125em;
height: 1.125em;
line-height: 1.125em;
border-radius: 2px;
text-align: center;
}
body .p-checkbox .p-checkbox-box .p-checkbox-icon {
overflow: hidden;
position: relative;
font-size: 18px;
}
.p-checkbox .p-checkbox-icon {
display: block;
}
body .p-datatable .p-datatable-tbody > tr.p-highlight {
background-color: $highlight_color;
color: #ffffff;
}

ReactCSSTransitionGroup simple example

I have been using ReactCSSTransitionGroup for basic animations - like slide in from left to right and right to left 2 images, but not able to acheive it - what am I missing here - the images animate but go back to their original position as soon as the animation is over - it is not looking good on the screen.
<ReactCSSTransitionGroup transitionName="square1" transitionAppear transitionEnterTimeout={1000}>
<img key={this.state.altText} alt="image" className="square-1" src="/images/sqr.svg" />
</ReactCSSTransitionGroup>
<ReactCSSTransitionGroup transitionName="square2" transitionAppear transitionEnterTimeout={1000}>
<img key={this.state.altText} alt="image" className="square-2" src="/images/sqr2.svg" />
</ReactCSSTransitionGroup>
css:
.square-1{
opacity: 0.4;
float:left;
position: absolute;
top:60px;
width: 150px;
left:-35px;
}
.square-2{
opacity: 0.4;
float:right;
width: 150px;
position: absolute;
right:-10px;
top:30px;
}
.square1{
position: absolute;
border:1px solid green;
left:10px;
top:90px;
}
.square1-appear {
opacity: 0.01;
transition: all 2s linear;
position:absolute;
left:-200px;
}
.square1-appear.square1-appear-active {
opacity: 0.4;
transition: all 2s ease-in;
position:absolute;
left:-30px;
top:-10px;
}
.square1-leave.square1-leave-active{
border:1px solid red;
}
.square2{
position: absolute;
right:10px;
top:30px;
}
.square2-appear {
opacity: 0.01;
transition: all 4s ease-in;
position:absolute;
right:-200px;
}
.square2-enter {
opacity: 0.01;
position:absolute;
right:-400px;
}
.square2-appear.square2-appear-active {
opacity: 0.8;
transition: all 2s ease-in;
position:absolute;
right:100px;
}

angular google maps window close button drifting

Our application in using Onsen and angular-google-maps. As shown in the example here, the "x" in the Google Maps InfoWindow is slowly drifting each time the map is reloaded.
All windows on the map open with the "x" in the same, correct, location the first time. Closing the map page popPage() and opening the map pushPage() causes the "x" to drift up and to the right 8px. The following is generated? and placed in the DOM below the content I put in the <ui-gmap-window> tags.
<div style="width: 19.5px; height: 19.5px; overflow: hidden; position: absolute; opacity: 0.7; transform: translateZ(0px); right: 15px; top: 12px; z-index: 10000;">
<img src="http://maps.gstatic.com/mapfiles/api-3/images/mapcnt3.png" draggable="false" style="position: absolute; left: -3px; top: -504px; width: 88.5px; height: 738px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px;">
</div>
Back and reopen:
<div style="width: 19.5px; height: 19.5px; overflow: hidden; position: absolute; opacity: 0.7; transform: translateZ(0px); right: 7px; top: 4px; z-index: 10000;">
<img src="http://maps.gstatic.com/mapfiles/api-3/images/mapcnt3.png" draggable="false" style="position: absolute; left: -3px; top: -504px; width: 88.5px; height: 738px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px;">
</div>
How can I determine what is causing this drift?
Update 2015-01-22:
I currently have a workaround.
function fixInfoWindow(){
$timeout(function(){
$(".gm-style-iw").each(function(){
if(this.parentNode.style.visibility != "hidden" && this.nextSibling != null){
this.nextSibling.style.right = "10px";
this.nextSibling.style.top = "8px";
this.nextSibling.nextSibling.style.right = "3px";
this.nextSibling.nextSibling.style.top = "1px";
}
});
});
}
This moves the "x" and the hidden item that closes the window when pressed to the proper location. I call this function at the end of the functions that set each InfoWindow visible.
My example can also be reproduced in Chrome with device emulation turned on.
I still have not found the cause of the drift.

Resources