What is the best way to change float:left
to float:right
for right-to-left language viewing on the same JSP file?
What is the best way to change float:left
to float:right
for right-to-left language viewing on the same JSP file?
Simply flipping it around with just CSS is not an option.
Here are a couple of alternatives:
ltr.css
and rtl.css
) each containing specific rules, then use server-side code to load the appropriate file.rtl
view, utilize JavaScript to loop through relevant elements and adjust their styles - jQuery makes this easy to implement, but it can also be accomplished with plain JavaScript..FLeft {
float: left !important;
}
.FRight {
float: right !important;
}
div.main-div[dir='rtl']>.FLeft {
float: right !important;
}
div.main-div[dir='rtl']>.FRight {
float: left !important;
}
div.child-div {
width: 50%;
background-color: #e6ffe6;
}
<div class="main-div">
<div>
<div class="FLeft child-div">1. Float left (default)</div>
<!-- For style= "float: left;" -->
</div>
<div style="clear:both"></div>
<div class="FLeft child-div" dir="rtl">2. Float left (rtl)</div>
<!-- For style="float: right"; ltr -->
<div style="clear:both"></div>
<div class="FRight child-div">3. Float right (default)</div>
<!-- For style= "float: right;" -->
<div style="clear:both"></div>
<div class="FRight child-div" dir="rtl">4. Float right (rtl)</div>
<!-- For style="float: right"; ltr-->
<div style="clear:both"></div>
</div>
<hr/>
<!-- Now for rtl text in div-main -->
<div class="main-div" dir="rtl">
<p>For dir rtl</p>
<div class="FLeft child-div">1. Float left</div>
<!-- For style= "float: left;" -->
<div style="clear:both"></div>
<div class="FLeft child-div " dir="ltr">2. Float left (ltr)</div>
<!-- For style="float: right"; rtl -->
<div style="clear:both"></div>
<div class="FRight child-div">3. Float right (default)</div>
<!-- For style= "float: right;" -->
<div style="clear:both"></div>
<div class="FRight child-div" dir="ltr">4. Float right (ltr)</div>
<!-- For style="float: right"; rtl-->
<div style="clear:both"></div>
</div>
Substitute the use of body or tag with dir="rtl" instead of div.main-div and use the FLeft and FRight classes instead of inline float styling. Please address the issue using CSS as my HTML Demo is not ideal. In the case of a right-to-left div, elements floated left should be floated to the right.
I am trying to center align my div containing login information on the webpage. The static values seem to work fine, but I am looking for a way to position it dynamically. Additionally, the background is only covering a strip with the height of the div... ...
I am experiencing a peculiar issue with my mobile menu. It works smoothly when the window is resized to below 736px, and the toggle animation adds CSS classes to animate the menu in and out. However, after resizing the window, opening and closing the mobi ...
I have inserted an image using the following CSS code: .imgtemp { float:right; top:0px; left:0px; overflow:visible; width:100%; } Although I have added the div tag to display it on the page, ...
When the report generator creates orders in html, it uses absolute positioning to ensure the exact layout from the report designer is preserved. Each order row contains a product description and price. Following the order row, there is a horizontal line o ...
Currently, I am working with a navigation view that utilizes the MatSidenavModule. The issue I am encountering is on mobile screens. When I click a mat-list-item, the mat-sidenav closes as expected. However, upon opening the mat-sidenav again, Material alw ...
I've spent countless hours customizing this element to perfection, but the more I work on it, the more of a headache it gives me. The element in question is an outlined TextField, and my focus has been on styling its label and border. Initially, I th ...
Before I reached out, I had been searching for a solution. In the process of building my website, I decided to incorporate text-shadow. It seemed straightforward, but turned out to be more complicated than expected. I discovered that IE does not support ...
HTML Code: <div class="tab"><h4>Zip Code</h4> <p><input type="text" class="text1" placeholder="Enter zip code..." oninput="this.className = ''" name="zipcode"></p> </div> <div class="tab">& ...
When attempting to pass data from one page to another routing page using [queryParams]="{'usd':usd, 'count' :country, 'name' :name}" through the routing button, it works perfectly fine but an error is displayed in my console. ...
I am working on setting up a database and login form, and I need to create a PHP script to validate the login credentials. What are the different types of data access and how can they be utilized? Specifically, how do I retrieve user input from elements ...
I'm facing a scenario where I have two tables and the challenge is to enable the user to establish a connection between rows from one table with rows from another. For example: When the user eventually clicks on the submit button, I require the infor ...
Recently, I challenged myself to create a complex input form that would enable users to add an infinite number of inventory items for efficient management. Throughout this process, I have sought assistance and have significantly enhanced my script with eac ...
Is there a way to display two months side by side using the FullCalendar plugin? I have not been able to find a solution in other similar questions. Here is my current setup: <div class="calendar-box"> <div clas ...
Looking for guidance on incorporating Javascript code into my Google Appscript. Here is the code snippet: I have a separate Stylesheet.html file saved. Can someone advise me on how to invoke the functions within the html file? <script> //google. ...
Recently, I inherited a project for a client who already has a fully developed website. This website functions similar to a social media platform like Twitter, where users can create accounts, post 'tweets', and gain followers. Upon examining t ...
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <div class="boxes"> <div class="red" style="width: 300px; height: 300px; color: red"></div> <div class="blue ...
I am facing an issue while trying to create a table of categories through recursive iteration of an array. The table generation works well when the depth increases, however, there seems to be a problem with the HTML output when the depth decreases. Below ...
I have been attempting to adjust the width of pink lines on this jsfiddle link: animation of object In my code, I am defining local basis vectors as follows: // Defining local vector axis of plane var thetadir = new THREE.Vector3(1, 0, 0); var phidir = ...
I'm currently working on a Bootstrap website and trying to make the navbar stick to the top. However, it seems like the class sticky-top isn't working as expected. Below is the code for the navbar: <div class="row"> <div class="col ...
For my coding practice, I am working on a project where clicking on the images should change the main product displayed along with its color. However, nothing happens when I click on the products. Can anyone point out what I might be doing wrong? Here is ...