logo
down
shadow

Conditional striped background with CSS


Conditional striped background with CSS

By : Samuel Tanor-Gyedu
Date : November 28 2020, 11:01 PM
it should still fix some issue I imagine you could use http://www.colorzilla.com/gradient-editor/ to obtain something like:
code :
.one{
   background:#ff0000;  
 }

.one.two{
   background: -moz-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,0,0,1) 50%, rgba(0,255,0,1) 50%, rgba(0,255,0,1) 50%, rgba(0,255,0,1) 100%); /* FF3.6-15 */
   background: -webkit-linear-gradient(left, rgba(255,0,0,1) 0%,rgba(255,0,0,1) 50%,rgba(0,255,0,1) 50%,rgba(0,255,0,1) 50%,rgba(0,255,0,1) 100%); /* Chrome10-25,Safari5.1-6 */
   background: linear-gradient(to right, rgba(255,0,0,1) 0%,rgba(255,0,0,1) 50%,rgba(0,255,0,1) 50%,rgba(0,255,0,1) 50%,rgba(0,255,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#00ff00',GradientType=1 ); /* IE6-9*/ 
}

.one.two.three{
   background: rgb(255,0,0); /* Old browsers */
   background: -moz-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,0,0,1) 33%, rgba(0,255,0,1) 33%, rgba(0,255,0,1) 33%, rgba(0,255,0,1) 66%, rgba(0,0,255,1) 66%, rgba(0,0,255,1) 66%); /* FF3.6-15 */
   background: -webkit-linear-gradient(left, rgba(255,0,0,1) 0%,rgba(255,0,0,1) 33%,rgba(0,255,0,1) 33%,rgba(0,255,0,1) 33%,rgba(0,255,0,1) 66%,rgba(0,0,255,1) 66%,rgba(0,0,255,1) 66%); /* Chrome10-25,Safari5.1-6 */
   background: linear-gradient(to right, rgba(255,0,0,1) 0%,rgba(255,0,0,1) 33%,rgba(0,255,0,1) 33%,rgba(0,255,0,1) 33%,rgba(0,255,0,1) 66%,rgba(0,0,255,1) 66%,rgba(0,0,255,1) 66%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#0000ff',GradientType=1 ); /* IE6-9 */  
} 


Share : facebook icon twitter icon
JTable with striped background

JTable with striped background


By : user2115141
Date : March 29 2020, 07:55 AM
This might help you Use getCellRect( getRowCount() - 1, 0, true ).y to get the top y-coordinate of the empty space, and then paint some Rectangles and (Grid-)Lines with paintComponent( Graphics g ).
code :
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

public class StripedEvenInWhitePartsTable extends JTable
{

  public StripedEvenInWhitePartsTable( String[][] data, String[] fields )
  {
    super( data, fields );
    setFillsViewportHeight( true ); //to show the empty space of the table 
  }


  @Override
  public void paintComponent( Graphics g )
  {
    super.paintComponent( g );

    paintEmptyRows( g );
  }


  public void paintEmptyRows( Graphics g )
  {
    Graphics newGraphics = g.create();
    newGraphics.setColor( UIManager.getColor( "Table.gridColor" ) );

    Rectangle rectOfLastRow = getCellRect( getRowCount() - 1, 0, true );
    int firstNonExistentRowY = rectOfLastRow.y; //the top Y-coordinate of the first empty tablerow

    if ( getVisibleRect().height > firstNonExistentRowY ) //only paint the grid if empty space is visible
    {
      //fill the rows alternating and paint the row-lines:
      int rowYToDraw = (firstNonExistentRowY - 1) + getRowHeight(); //minus 1 otherwise the first empty row is one pixel to high
      int actualRow = getRowCount() - 1; //to continue the stripes from the area with table-data

      while ( rowYToDraw < getHeight() )
      {
        if ( actualRow % 2 == 0 )
        {
          newGraphics.setColor( Color.ORANGE ); //change this to another color (Color.YELLOW, anyone?) to show that only the free space is painted
          newGraphics.fillRect( 0, rowYToDraw, getWidth(), getRowHeight() );
          newGraphics.setColor( UIManager.getColor( "Table.gridColor" ) );
        }

        newGraphics.drawLine( 0, rowYToDraw, getWidth(), rowYToDraw );

        rowYToDraw += getRowHeight();
        actualRow++;
      }


      //paint the column-lines:
      int x = 0;
      for ( int i = 0; i < getColumnCount(); i++ )
      {
        TableColumn column = getColumnModel().getColumn( i );
        x += column.getWidth(); //add the column width to the x-coordinate

        newGraphics.drawLine( x - 1, firstNonExistentRowY, x - 1, getHeight() );
      }

      newGraphics.dispose();

    } //if empty space is visible

  } //paintEmptyRows



  public Component prepareRenderer( TableCellRenderer renderer, int row, int column )
  {
    Component c = super.prepareRenderer( renderer, row, column );

    if ( !isRowSelected( row ) )
    {
      c.setBackground( row % 2 == 0 ? getBackground() : Color.ORANGE );
    }

    return c;
  }


  public static void main( String[] argv )
  {
    String data[][] = { { "A0", "B0", "C0" }, { "A1", "B1", "C1" }, { "A2", "B2", "C2" }, { "A3", "B3", "C3" }, { "A4", "B4", "C4" } };
    String fields[] = { "A", "B", "C" };

    JFrame frame = new JFrame( "a JTable with striped empty space" );
    StripedEvenInWhitePartsTable table = new StripedEvenInWhitePartsTable( data, fields );
    JScrollPane pane = new JScrollPane( table );

    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.add( pane );
    frame.setSize( 400, 300 );
    frame.setLocationRelativeTo( null );
    frame.setVisible( true );
  }

}
Vertical-striped background in XML?

Vertical-striped background in XML?


By : wangjinting
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Unfortunate, but I'm pretty sure the answer is no.
Of the three tasks required, only two could be done without any code. You can create the base of the stripes pattern as a of two or more items. You can also create a repeating tile pattern using a XML drawable. The trick is the required middle step: will not accept another drawable as a source value (only an image) so there is no way to link the two without the intervention of a little code to create a Bitmap (like what you have written).
Striped background in d3pie.js

Striped background in d3pie.js


By : user3410949
Date : March 29 2020, 07:55 AM
With these it helps You could use SVG pattern fill and mask to achieve this: http://jsfiddle.net/henbox/wt45qfkz/2/
The pattern is borrowed from this answer to a previous question.
code :
var arcs = vis.selectAll("g.slice")
  .data(pie).enter()
  .append("svg:g")
  .attr("class", "slice")
  .attr("style", "fill:url(#stripe);")
  .attr("style", "mask:url(#mask);");
CSS only 2 striped background (skewed)

CSS only 2 striped background (skewed)


By : azhar shaikh
Date : March 29 2020, 07:55 AM
like below fixes the issue You can do this with linear-gradient
code :
body, html {
  margin: 0;
  padding: 0;
}

div {
  min-height: 100vh;
  background: linear-gradient(65deg, white 50%, #5C8F09 50%);
}
<div></div>
striped background for the border of a div

striped background for the border of a div


By : 福利吧
Date : March 29 2020, 07:55 AM
this one helps. Use border images:
http://css-tricks.com/understanding-border-image/
Related Posts Related Posts :
  • How can I get an icon verically centered inside a button with Semantic UI
  • Center align a div - margin:0 auto; width:980; display:block; not working
  • Is it possible to place absolut positioned elements automatically among themselves?
  • Applying a CSS transform before animation
  • Bootstrap - do we have to use rows and columns?
  • Change the theme of one page without changing menu, search bar... in WordPress
  • Bookdown: How can I change the size of the chapter titles?
  • Bootstrap Media Queries
  • how to remove a css class dynamically in ionic
  • color and background-color helper
  • CSS: Absolute(?) positioning skewed element (no JS !important)
  • Why is my background image not displaying?
  • Server Push not working on Repeat View
  • Position pseudoelement between track and thumb of input type range
  • Correct way to use external template in meteor mantra
  • How to use an unicode character instead of a background image?
  • How to get OS X like scrollbars on all platforms
  • Different durations for start and end of transitions?
  • Adding background color changes width of bootstrap grid element?
  • map for using sass in bootstrap for bower project
  • Adding CSS to an AJAX popup alert
  • How do I create full width video similar to graphicstock.com's video banner?
  • How to specify the system’s default serif and sans-serif font-family?
  • Is there a way to change the relative position value of an element by browser?
  • Is there a simple way to know how many rows are in a wrapped Flexbox?
  • How to get CSS or XPath locator from a button class
  • How can I add a border to the right side of this object?
  • Angular Material - Setting fixed widths?
  • Safari / Chrome - Flexbox grid
  • Share buttons issue
  • HTML5 Video with custom controls
  • How to set the CSS content property with a Google Material Icon?
  • How do I do this animated underline hover effect?
  • ASP.NET Bootstrap wrong display
  • Chrome leaves white space/gap in between when rendering multiple gradients
  • WebStorm scss compiler error with transition/transform
  • How to change background colour of left menu in Inspinia
  • Button reverts to pre-programmed pseudo-class colors, CSS
  • CSS Border on the inside of div
  • formatting vertical text in divs
  • How to Create Different Styles for input[type=checkbox]?
  • Scaling and rotating an image inside a border
  • Possible to have an initial width of textarea but leave it adjustable?
  • Navbar layers on top of logo
  • Wired CSS rendered in chrome (but not in Safari)
  • x-editable not working with bootstrap 3 in django
  • Image in site root renders locally but not on IIS server
  • Firefox doesn't load CSS file
  • Overriding the encapsulated CSS of external component
  • "dropdown-toggle" down on default
  • gap below image using flexbox in ie11
  • CSS border/outline who goes on top of a line of text
  • Horizontally scrollable div not completely visible
  • Issues with v4 bootstrap classes
  • New line in HTML creates implicit margin
  • Loading an text over an image without text moving when screen size changes
  • How to make the value of select element to the center position in the Bootstrap framework
  • Zoom out shiny app at default in browser
  • Double top border of which one is centered with a certain width on one element
  • How to create a panel in HTML
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com